All pastes #964348 Raw Edit

Someone

public text v1 · immutable
#964348 ·published 2008-03-31 04:09 UTC
rendered paste body
#!/bin/bash
PATH="/sbin:/usr/sbin:/usr/local/sbin";
slaveIfs="1 2 3 4 6 7 8 9 10";

echo "1" > /proc/sys/net/ipv4/ip_forward;
#chown root:vboxusers /dev/net/tun;
#chmod g+rw /dev/net/tun;

cmd="$1";
[ -z "$cmd" ] && cmd="start";
case "$cmd" in
  start)
    brctl addbr br0;
    brctl stp br0 off;
    tunctl -t tap1 -u nande
    brctl addif br0 eth0;
    brctl addif br0 tap1;
    (ifdown eth0 1>/dev/null 2>&1;);
    (ifdown tap1 1>/dev/null 2>&1;);
    (ifdown bnep0 1>/dev/null 2>&1;);
    ifconfig eth0 0.0.0.0 promisc up;
    ifconfig tap1 0.0.0.0 promisc up;
    ifconfig br0 192.168.1.99 broadcast 192.168.1.255 netmask 255.255.255.0 up; ### Adapt to your needs.
    route add default gw 192.168.1.1; ### Adapt to your needs.
    for file in br0 eth0 tap1;
    do
      echo "1" > /proc/sys/net/ipv4/conf/${file}/proxy_arp;
      echo "1" > /proc/sys/net/ipv4/conf/${file}/forwarding;
    done;
    echo "1" > /proc/sys/net/ipv4/ip_forward;
    ;;
  stop)
    brctl delif br0 eth0;
    brctl delif br0 tap1;
    (brctl delif bnep01 1>/dev/null 2>&1;);
    ifconfig br0 down;
    brctl delbr br0;
    #ifup eth0; ### Adapt to your needs.
    #ifup eth1; ### Adapt to your needs.
    ;;
  restart,reload)
    $0 stop;
    sleep 3;
    $0 start;
    ;;
esac;