1 #!/bin/bash
2 # 2008-01-29 by SDK, dirty hack to quickly change network device
3 # call _lan2 wlan0 eth0 to switch from wlan to eth0
4
5 FROM=$1
6 TO=$2
7
8 IPADDR=`ifconfig | grep -h1 $FROM | grep inet | cut -d":" -f2 | cut -d" " -f1 | strings`
9 ROUTE=`route -n | grep $FROM | cut -b17-28 | grep -v "0.0.0.0"`
10
11 echo "Got IP: $IPADDR and Route: $ROUTE from $FROM."
12
13 ifdown $FROM
14 ifconfig FROM down
15
16 ifconfig $TO $IPADDR up;
17 route add default gw $ROUTE