summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/runqemu-ifup15
1 files changed, 3 insertions, 12 deletions
diff --git a/scripts/runqemu-ifup b/scripts/runqemu-ifup
index 8948153..5f6a437 100755
--- a/scripts/runqemu-ifup
+++ b/scripts/runqemu-ifup
@@ -80,16 +80,6 @@ if [ ! -x "$IFCONFIG" ]; then
80 exit 1 80 exit 1
81fi 81fi
82 82
83ROUTE=`which route`
84if [ "x$ROUTE" = "x" ]; then
85 # better than nothing...
86 ROUTE=/sbin/route
87fi
88if [ ! -x "$ROUTE" ]; then
89 echo "$ROUTE cannot be executed"
90 exit 1
91fi
92
93IPTABLES=`which iptables 2> /dev/null` 83IPTABLES=`which iptables 2> /dev/null`
94if [ "x$IPTABLES" = "x" ]; then 84if [ "x$IPTABLES" = "x" ]; then
95 IPTABLES=/sbin/iptables 85 IPTABLES=/sbin/iptables
@@ -100,10 +90,11 @@ if [ ! -x "$IPTABLES" ]; then
100fi 90fi
101 91
102n=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ] 92n=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ]
103$IFCONFIG addr add 192.168.7.$n/32 dev $TAP 93$IFCONFIG addr add 192.168.7.$n/32 broadcast 192.168.7.255 dev $TAP
94$IFCONFIG link set dev $TAP up
104 95
105dest=$[ (`echo $TAP | sed 's/tap//'` * 2) + 2 ] 96dest=$[ (`echo $TAP | sed 's/tap//'` * 2) + 2 ]
106$ROUTE add -host 192.168.7.$dest $TAP 97$IFCONFIG route add to 192.168.7.$dest dev $TAP
107 98
108# setup NAT for tap0 interface to have internet access in QEMU 99# setup NAT for tap0 interface to have internet access in QEMU
109$IPTABLES -A POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$n/32 100$IPTABLES -A POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$n/32