Hi matzi
Forget that because there is no action "remove" available for eth0, we must make rule on your wlan0.
BUS=="usb", SUBSYSTEM=="net", KERNEL=="wlan0", ACTION=="add", RUN="/etc/iface_scripts/bringup_wlan0.sh"
BUS=="usb", SUBSYSTEM=="net", KERNEL=="wlan0", ACTION=="remove", RUN="/etc/iface_scripts/bringdown_wlan0.sh"
# ifconfig eth0 up
# /sbin/route add default gw 192.168.178.1 dev eth0
# ifconfig wlan0 down
echo "bringdownwlan0" >> /etc/iface_scripts/udev.log
# ifconfig wlan0 up
# ifconfig eth0 down
echo "bringupwlan0" >> /etc/iface_scripts/udev.log
Note2: in your shell script, you must use the command with their full path (e.g. /sbin/route) because the PATH environment variable is not available.
which ifconfig
/sbin/ifconfig wlan0 up
/sbin/route add default gw 192.168.178.1 dev wlan0
/sbin/ifconfig eth0 down
/usr/bin/echo "bringupwlan0" >> /etc/iface_scripts/udev.log
# /sbin/ifconfig eth0 up
# /sbin/route add default gw 192.168.178.1 dev eth0
# /sbin/ifconfig wlan0 down
/usr/bin/echo "bringdownwlan0" >> /etc/iface_scripts/udev.log
# /sbin/ifconfig wlan0 up
# /sbin/route add dafault gw 192.168.178.1 dev wlan0
# /sbin/ifconfig eth0 down
/usr/bin/echo "bringupwlan0" >> /etc/iface_scripts/udev.log
udevinfo -a -p /sys/class/net/wlan0
find /sys/class -name wlan0
udevinfo starts with the device the node belongs to and then walks up the
device chain, to print for every device found, all possibly useful attributes
in the udev key format.
Only attributes within one device section may be used together in one rule,
to match the device for which the node will be created.
looking at device '/devices/platform/orion-ehci.0/usb1/1-1/1-1:1.0/net/wlan0':
KERNEL=="wlan0"
SUBSYSTEM=="net"
SYSFS{mtu}=="1500"
SYSFS{type}=="1"
SYSFS{netdev_group}=="0"
SYSFS{flags}=="0x1002"
SYSFS{addr_assign_type}=="0"
SYSFS{dev_id}=="0x0"
SYSFS{iflink}=="6"
SYSFS{addr_len}=="6"
SYSFS{address}=="7c:dd:90:16:ee:e9"
SYSFS{operstate}=="down"
SYSFS{broadcast}=="ff:ff:ff:ff:ff:ff"
SYSFS{tx_queue_len}=="1000"
SYSFS{ifalias}==""
SYSFS{ifindex}=="6"
SYSFS{link_mode}=="0"
looking at device '/devices/platform/orion-ehci.0/usb1/1-1/1-1:1.0/net':
ID=="net"
BUS==""
DRIVER==""
looking at device '/devices/platform/orion-ehci.0/usb1/1-1/1-1:1.0':
ID=="1-1:1.0"
BUS=="usb"
DRIVER=="rt2800usb"
SYSFS{bInterfaceClass}=="ff"
SYSFS{modalias}=="usb:v148Fp5370d0101dc00dsc00dp00icFFiscFFipFFin00"
SYSFS{bInterfaceSubClass}=="ff"
SYSFS{bInterfaceProtocol}=="ff"
SYSFS{bNumEndpoints}=="07"
SYSFS{supports_autosuspend}=="0"
SYSFS{bAlternateSetting}==" 0"
SYSFS{bInterfaceNumber}=="00"
SYSFS{interface}=="1.0"
looking at device '/devices/platform/orion-ehci.0/usb1/1-1':
ID=="1-1"
BUS=="usb"
DRIVER=="usb"
SYSFS{dev}=="189:1"
SYSFS{bDeviceSubClass}=="00"
SYSFS{bDeviceProtocol}=="00"
SYSFS{devpath}=="1"
SYSFS{idVendor}=="148f"
SYSFS{speed}=="480"
SYSFS{bNumInterfaces}==" 1"
SYSFS{bConfigurationValue}=="1"
SYSFS{bMaxPacketSize0}=="64"
SYSFS{busnum}=="1"
SYSFS{devnum}=="2"
SYSFS{configuration}==""
SYSFS{bMaxPower}=="450mA"
SYSFS{authorized}=="1"
SYSFS{bmAttributes}=="80"
SYSFS{bNumConfigurations}=="1"
SYSFS{maxchild}=="0"
SYSFS{bcdDevice}=="0101"
SYSFS{avoid_reset_quirk}=="0"
SYSFS{quirks}=="0x0"
SYSFS{serial}=="1.0"
SYSFS{version}==" 2.00"
SYSFS{urbnum}=="140"
SYSFS{ltm_capable}=="no"
SYSFS{manufacturer}=="Ralink"
SYSFS{removable}=="unknown"
SYSFS{idProduct}=="5370"
SYSFS{bDeviceClass}=="00"
SYSFS{product}=="802.11 n WLAN"
looking at device '/devices/platform/orion-ehci.0/usb1':
ID=="usb1"
BUS=="usb"
DRIVER=="usb"
SYSFS{dev}=="189:0"
SYSFS{bDeviceSubClass}=="00"
SYSFS{bDeviceProtocol}=="01"
SYSFS{devpath}=="0"
SYSFS{idVendor}=="1d6b"
SYSFS{speed}=="480"
SYSFS{bNumInterfaces}==" 1"
SYSFS{bConfigurationValue}=="1"
SYSFS{bMaxPacketSize0}=="64"
SYSFS{authorized_default}=="1"
SYSFS{busnum}=="1"
SYSFS{devnum}=="1"
SYSFS{configuration}==""
SYSFS{bMaxPower}=="0mA"
SYSFS{authorized}=="1"
SYSFS{bmAttributes}=="e0"
SYSFS{bNumConfigurations}=="1"
SYSFS{maxchild}=="1"
SYSFS{bcdDevice}=="0309"
SYSFS{avoid_reset_quirk}=="0"
SYSFS{quirks}=="0x0"
SYSFS{serial}=="orion-ehci.0"
SYSFS{version}==" 2.00"
SYSFS{urbnum}=="37"
SYSFS{ltm_capable}=="no"
SYSFS{manufacturer}=="Linux 3.9.5 ehci_hcd"
SYSFS{removable}=="unknown"
SYSFS{idProduct}=="0002"
SYSFS{bDeviceClass}=="09"
SYSFS{product}=="Marvell Orion EHCI"
looking at device '/devices/platform/orion-ehci.0':
ID=="orion-ehci.0"
BUS=="platform"
DRIVER=="orion-ehci"
SYSFS{modalias}=="platform:orion-ehci"
SYSFS{uframe_periodic_max}=="100"
looking at device '/devices/platform':
ID=="platform"
BUS==""
DRIVER==""
SYSFS{uevent}==""
SUBSYSTEM=="net", KERNEL=="wlan0", ACTION=="add", RUN+="/bin/sh /etc/iface_scripts/bringup_wlan0.sh"
SUBSYSTEM=="net", KERNEL=="wlan0", ACTION=="remove", RUN+="/bin/sh /etc/iface_scripts/bringdown_wlan0.sh"
Users browsing this forum: No registered users and 12 guests