detect wired connection with udev?
Hi I've been trying to figure out a way to detect when eth0 is plugged in using udev.
when unplugged: Code:
dmesg | grep eth0 | tail -1 Code:
dmesg | grep eth0 | tail -2 Code:
KERNEL=="eth0", RUN+="/etc/rc.d/rc.inetmon" Code:
KERNEL=="eth0", RUN+="/etc/rc.d/rc.inet1 restart" I know there is netplug but imo a daemon should not be added if udev can do this already. thanks for looking. btw- dell d820, core duo, adapter is Broadcomm ( BCM5752), linux 2.6.22.9, zenwalk 4.8 |
Can you get what you want by using the ifconfig command with no parameters?
ifconfig ----------------- Steve Stites |
thanks for the reply, I'm not sure I understand how I'd do that without a daemon.
It seems to me - my problem is not getting udev to recognize when the cable is unplugged/replugged. polling ifconfig is more a daemon-like approach, isn't it? I'm looking for some udev event (kernel message, sysfs attribute) that a udev rule can use to detect activity of the eth0 interface. Then I'd make it run a script to reroute traffic to include/exclude it and/or que the wireless interface to start up. |
Quote:
If you want to see all udev events as they occur, try something like this (this gives you the kernel-side events, the udev-side events and a matchable environment): Code:
udevmonitor -keu |
Quote:
at the risk of derailing my op, I have now tried ifplugd : Code:
if gcc -DHAVE_CONFIG_H -I. -I. -I.. -D_REENTRANT -DSYSCONFDIR="\"/etc\"" -D_GNU_SOURCE -march=prescott -O2 -pipe -fomit-frame-pointer -mfpmath=sse -msse3 -pipe -W -Wall -Wno-unused-parameter -MT interface.o -MD -MP -MF ".deps/interface.Tpo" -c -o interface.o interface.c; \ Code:
$ make -ed- nevermind, got netplug to build. |
All times are GMT -5. The time now is 09:42 AM. |