Test for configured ethX - Networking

This is a discussion on Test for configured ethX - Networking ; 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 ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Test for configured ethX

  1. 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

  2. Re: Test for configured ethX

    2007-03-28, 09:44(-08), CptDondo:
    > 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.

    [...]

    I would use dhclient-script hooks. See:

    man dhclient-script

    --
    Stéphane

+ Reply to Thread