Test for configured ethX



I have a machine that travels. I want to configure it differently when it is attached to a local network and when it is not.

So...

Is there an easy way to test if ethX (eth1 in my case) has received an IP address via DHCP?

What I want is something like this:

Try to get a DHCP address
If you succeed, do the following
copy network database config file to our config
If you fail, do the following
copy local database config file to our config
start local mysqld

Nothing too complex.... But I can't seem to find a reliable test for the DHCP assignment.

The box is running Debian Etch, if that matters....

--Yan
.



Relevant Pages

  • Re: Test for configured ethX
    ... it is attached to a local network and when it is not. ... IP address via DHCP? ... copy network database config file to our config ... I would use dhclient-script hooks. ...
    (comp.os.linux.networking)
  • Re: [SLE] DHCP vs Static IP - SUSE 10.0
    ... > DHCP provided by my ISP to go outside my local network to the Internet. ... > 192.168.100.10 toshiba.site toshiba ...
    (SuSE)
  • Re: nameserver?
    ... >>cable modem with DHCP, or what? ... Then your entire internet connection is hosed. ... problem than just the nameserver issue. ... I would suggest de-configuring your local network ...
    (comp.os.linux.misc)
  • named config
    ... This works fine, I can resolve most of my local network, as well as the wide ... (coincidental with my laptop renewing its lease with DHCP): ... tony-lw.magpieway.net, but doesn't (It's not in the zone file, of course). ...
    (uk.comp.os.linux)
  • Re: hostname doesnt stick
    ... local DNS server for all the local network addresses. ... Though I keep one machine dynamically on DHCP ...
    (Fedora)