Re: How to know if the cable is connected to the interface
Hi,
On 2004-11-27, Osiris <Osiris@gizeh.eg> wrote:
> Hi,
> 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.
>
'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.
> 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.
>
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 route says that the default gw is wlan0, but eth0 is set first.
> Any idea ?
>
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
Alex
|