Listing 1. setup_network_connections.sh ###### create the br0 and br1 bridge with the brctl utility brctl addbr br0 brctl addbr br1 ##### delete all old configurations if they exist ifconfig br0 0.0.0.0 down brctl delif br0 tap0 brctl delif br0 tap1 ifconfig br1 0.0.0.0 down brctl delif br1 tap3 brctl delif br1 tap4 ##### flush all filter and nat rules iptables -t nat -F iptables -F ##### turn on debug prints set -x #### make all tap interfaces up. ifconfig tap0 0.0.0.0 up ifconfig tap1 0.0.0.0 up ifconfig tap3 0.0.0.0 up ifconfig tap4 0.0.0.0 up #### add tap0 and tap1 to br0 bridge brctl addif br0 tap0 brctl addif br0 tap1 #### add tap3 and tap4 to br1 bridge brctl addif br1 tap3 brctl addif br1 tap4 ##### assign br0 with 192.168.10.1 ip and make it up ifconfig br0 192.168.10.1 netmask 255.255.255.0 up ##### assign br1 with 192.168.30.1 ip and make it up ifconfig br1 192.168.30.1 netmask 255.255.255.0 up ##### assign tap2 interface with 192.168.20.1 ip and make it up ifconfig tap2 192.168.20.1 netmask 255.255.255.0 up ##### enable ip forward echo 1 > /proc/sys/net/ipv4/ip_forward ##### make the default policy of the forward chain as accept ##### to avoid any possibility of dropping packets in filter chain iptables -P FORWARD ACCEPT ##### add a NAT rule to Masquerade packets from uml-R to the host machine. iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE