How to know if the cable is connected to the interface

Discussion in 'Linux Networking' started by Osiris, Nov 27, 2004.

  1. Osiris

    Osiris Guest

    I'd like to know if there is a way to know whether the cable is connected
    to my interface. The aim is to detect it at startup so as to know if I need
    eth0 set up or not (on a laptop), in which case (if not needed) only the
    wifi card is set up.

    In fact the problem is that if the wifi card AND the eth0 interface are
    both set up, I cannot use the wifi card, even if the cable is not plugged
    to the eth0 interface.

    My route says that the default gw is wlan0, but eth0 is set first.
    Any idea ?
    Osiris, Nov 27, 2004
    1. Advertisements

  2. Hi,

    'ethtool' or the old fashion 'mii-diag'/'mii-tool'. I would recommend you
    have a look at 'whereami' to do a lot of the autodetection; this also would
    include you telling it tests it can do on the ethernet port to detect *where*
    your laptop is plugged in (work or office?) with ARP pings/mappings and such.
    Tis all lies, what you cannot do (without knowing about metrics and more
    advanced routing magic) is having two default gateways; your computer does
    not know which interface to route traffic out on and then gets confused with
    the return traffic; if I remember correctly.
    My plan would be to munch through 'ethtool eth0' with awk/bash to see if the
    cable is plugged in, if not start detecting and configuring the wifi. If the
    cable is plugged in then configure it depending on the environment you have
    plugged it into.

    Tis what I do afterall :)

    Have fun

    Alexander Clouter, Nov 27, 2004
    1. Advertisements

  3. Osiris

    Tauno Voipio Guest

    Google for iplugd - interface plug daemon.

    I'm using it just now on this laptop in the way
    you requested.

    Tauno Voipio, Nov 28, 2004
  4. Osiris

    James Knott Guest

    You could write a script to turn down one interface and bring up the other.
    Another possibility, is to use profiles. You'd create a profile for each
    configuration. You can then switch profiles at any time, or even at boot
    James Knott, Nov 28, 2004
  5. Osiris

    Osiris Guest

    Thanks for all the precious info

    What is the usual doc/howto to read to get a multiprofile boot up ?
    Osiris, Dec 1, 2004
  6. Osiris

    James Knott Guest

    That would depend on your distro. I use SuSE, so the searching the help for
    SCPM has the info. As for booting into different profiles, that would be
    covered under Grub or lilo.
    James Knott, Dec 1, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.