basic question about assigning ip address

Adalbert Prokop adalbert.prokop at gmx.de
Sun Sep 30 14:39:49 UTC 2007


Peter Horst wrote on Sunday 30 September 2007:

> I have a Fedora machine I'm using as a home server, without a keyboard
> or monitor. I'd like to set it up such that upon rebooting it first
> checks to see if there is a DHCP server on the network, and if so,
> grabs an ip address from it.  But if there isn't one, it assigns itself
> a static address.  Is this doable?

Yes, it's possible, but I agree with Jacques and Ed, that it is not 
desirable. A server should use a static address. So much for an advise.

What you want is possible using dhclient hooks. Those are scripts called 
by dhclient. Depending on the status dhclient provides to them they can 
do anything a script can do. "man dhclient-script" is your friend.

I use those scripts on my notebook to setup IPv4LL addresses (local link 
adresses, 169.254.0.0) if there is no DHCP server available. Together 
with Avahi they make ad-hoc networks really easy.

I attach both dhclient-hooks as example how to use hooks. They both live 
in /etc and should be executable.

-- 
Bye,
Adalbert

"Mach was the greatest intellectual fraud in the last ten years." "What 
about X?" "I said `intellectual'." ;login, 9/1990
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dhclient-enter-hooks
Type: application/x-shellscript
Size: 1025 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20070930/b28c4298/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dhclient-exit-hooks
Type: application/x-shellscript
Size: 1027 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20070930/b28c4298/attachment-0003.bin>


More information about the fedora-list mailing list