Re: basic question about assigning ip address



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

Attachment: dhclient-enter-hooks
Description: application/shellscript

Attachment: dhclient-exit-hooks
Description: application/shellscript

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list

Relevant Pages

  • Re: Instructing dhclient to set hostname of client
    ... JH>>> If you're talking about a laptop where you're not sure what the DHCP ... JH>> What you think about adding a new feature to dhclient - Alternate IP ... after other net scripts, and basically gets the ip from $interface (set ...
    (freebsd-net)
  • Re: 2 NICs sharing a cable internet connection
    ... This means nothing except that you haven't run dhclient, ... and run "dhclient eth0". ... Do ifconfig eth0 up. ... Do not use scripts! ...
    (comp.os.linux.misc)
  • Re: dhclient and host resolution
    ... you have to tell the DHCP server to also provide to the client ... gateway and DNS information explicitly. ... respectively when I work @home from my DSL provider. ... So dhclient is able to do that, ...
    (freebsd-questions)
  • Re: ip address on lan getting hijacked
    ... router which has an address of 192.168.1.1. ... down and reset to 192.168.1.100, apparently by dhclient accessing the ... entry in the DHCP server to assign the same address to a particular MAC ...
    (Ubuntu)
  • Re: hostname curiosity [SOLVED] ...but curioser and curioser
    ... Now there is a longer pause during booting when it gets ... little longer to get an answer from the dhcp server. ... the '-1' option is given to dhclient. ... It should be set to the hostname you desire. ...
    (Fedora)