-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdsr-uu.sh
executable file
·57 lines (50 loc) · 1.33 KB
/
dsr-uu.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
command=$1
IFNAME=eth1
DSRUUPATH=/lib/modules/`uname -r`/dsr/
MODPREFIX=ko
killproc() {
pidlist=$(/sbin/pidof $1)
for pid in $pidlist; do
kill $pid &>/dev/null
done
return 0
}
if [ -z "$1" ]; then
echo "Must specify \"start\" or \"stop\""
exit
fi
if [ -n "$2" ]; then
IFNAME=$2
fi
echo "Slave interface is $IFNAME"
if [ "$command" = "start" ]; then
# Start DSR-UU
IP=`/sbin/ifconfig $IFNAME | grep inet`
IP=${IP%%" Bcast:"*}
IP=${IP##*"inet addr:"}
echo $IP > .$IFNAME.ip
host_nr=`echo $IP | awk 'BEGIN{FS="."} { print $4 }'`
if [ -f $DSRUUPATH/linkcache.$MODPREFIX ] && [ -f $DSRUUPATH/dsr.$MODPREFIX ]; then
# Reconfigure the default interface
insmod $DSRUUPATH/linkcache.$MODPREFIX
insmod $DSRUUPATH/dsr.$MODPREFIX ifname=$IFNAME
#/sbin/ifconfig $IFNAME 192.168.45.$host_nr up
/sbin/ifconfig dsr0 192.168.45.$host_nr up
# Disable debug output
echo "PrintDebug=1" > /proc/net/dsr_config
echo "DSR-UU started with virtual host IP $IP"
# Enable IP-forwarding...
#echo 1 > /proc/sys/net/ipv4/ip_forward
#echo 0 > /proc/sys/net/ipv4/conf/$IFNAME/rp_filter
else
echo "DSR-UU not installed"
exit
fi
elif [ "$command" = "stop" ]; then
IP=`cat .$IFNAME.ip`
/sbin/ifconfig dsr0 down
rmmod dsr linkcache
# /sbin/ifconfig $IFNAME $IP up
rm -f .dsr.ip
fi