basic question about assigning ip address

Jacques B. jjrboucher at gmail.com
Sun Sep 30 03:12:42 UTC 2007


On 9/29/07, Peter Horst <phorst at speakeasy.net> wrote:
> 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?
>
> Thank you.
>
I should have asked, do you have admin control over the dhcp server?
Are you able to have it assign a static IP to your server based on its
MAC address?  If so why not do that, then automatically assign it that
IP without worrying about the DHCP server knowing that the IP has been
reserved for your MAC so no danger of conflict on the subnet.

Another possible solution (I'd have to do some digging to figure this
one out but I'm sure it can be done) is to monitor traffic on your NIC
with tcpdump, filtering for DHCP response.  If none is captured then
assign a static IP.  Here again it would rely on a script that would
run at the end of the boot cycle to check the captured traffic and
examine for that DHCP response.  Much easier to simply check via
ifconfig if your card got an IP or not.  However if you are looking to
take it further than that to ascertain if it even spoke with the DHCP
server then tcpdump could assist you with that.

Jacques B.




More information about the users mailing list