diff options
Diffstat (limited to 'scripts/runqemu-ifup')
| -rwxr-xr-x | scripts/runqemu-ifup | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/scripts/runqemu-ifup b/scripts/runqemu-ifup index 987a37a1a7..870cb6bcb7 100755 --- a/scripts/runqemu-ifup +++ b/scripts/runqemu-ifup | |||
| @@ -69,12 +69,29 @@ if [ "x$IFCONFIG" = "x" ]; then | |||
| 69 | # better than nothing... | 69 | # better than nothing... |
| 70 | IFCONFIG=/sbin/ifconfig | 70 | IFCONFIG=/sbin/ifconfig |
| 71 | fi | 71 | fi |
| 72 | if [ ! -x "$IFCONFIG" ]; then | ||
| 73 | echo "$IFCONFIG cannot be executed" | ||
| 74 | exit 1 | ||
| 75 | fi | ||
| 72 | 76 | ||
| 73 | ROUTE=`which route` | 77 | ROUTE=`which route` |
| 74 | if [ "x$ROUTE" = "x" ]; then | 78 | if [ "x$ROUTE" = "x" ]; then |
| 75 | # better than nothing... | 79 | # better than nothing... |
| 76 | ROUTE=/sbin/route | 80 | ROUTE=/sbin/route |
| 77 | fi | 81 | fi |
| 82 | if [ ! -x "$ROUTE" ]; then | ||
| 83 | echo "$ROUTE cannot be executed" | ||
| 84 | exit 1 | ||
| 85 | fi | ||
| 86 | |||
| 87 | IPTABLES=`which iptables 2> /dev/null` | ||
| 88 | if [ "x$IPTABLES" = "x" ]; then | ||
| 89 | IPTABLES=/sbin/iptables | ||
| 90 | fi | ||
| 91 | if [ ! -x "$IPTABLES" ]; then | ||
| 92 | echo "$IPTABLES cannot be executed" | ||
| 93 | exit 1 | ||
| 94 | fi | ||
| 78 | 95 | ||
| 79 | n=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ] | 96 | n=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ] |
| 80 | $IFCONFIG $TAP 192.168.7.$n | 97 | $IFCONFIG $TAP 192.168.7.$n |
| @@ -83,11 +100,6 @@ dest=$[ (`echo $TAP | sed 's/tap//'` * 2) + 2 ] | |||
| 83 | $ROUTE add -host 192.168.7.$dest $TAP | 100 | $ROUTE add -host 192.168.7.$dest $TAP |
| 84 | 101 | ||
| 85 | # setup NAT for tap0 interface to have internet access in QEMU | 102 | # setup NAT for tap0 interface to have internet access in QEMU |
| 86 | IPTABLES=`which iptables` | ||
| 87 | if [ "x$IPTABLES" = "x" ]; then | ||
| 88 | IPTABLES=/sbin/iptables | ||
| 89 | fi | ||
| 90 | |||
| 91 | $IPTABLES -A POSTROUTING -t nat -j MASQUERADE -s 192.168.7.0/24 | 103 | $IPTABLES -A POSTROUTING -t nat -j MASQUERADE -s 192.168.7.0/24 |
| 92 | echo 1 > /proc/sys/net/ipv4/ip_forward | 104 | echo 1 > /proc/sys/net/ipv4/ip_forward |
| 93 | $IPTABLES -P FORWARD ACCEPT | 105 | $IPTABLES -P FORWARD ACCEPT |
