How to setup Debian Linux Wheezy TUN/TAP Bridge Print

  • TUN/TAP, Debian, linux
  • 30

Pre-requisites

  • Install bridge-utils and uml-utilities (tunctl). Load TUN module by "modprobe tun" in Debian server.

apt-get install bridge-utils
apt-get install uml-utilities

  • Check CONFIG_TUN is enabled in the kernel: 

grep CONFIG_TUN /boot/config-`uname -r`

Setup

br0 is host NIC. Guest OS interface will write to tap0. Bridge interface exists between eth0 and tap0.

Configure /etc/network/interfaces

auto tap0

iface tap0 inet static

        pre-up tunctl -u root -t tap0

        address 172.20.0.1

        netmask 255.255.255.0

auto br0

 iface br0 inet static

        address 192.168.1.211

        network 192.168.1.0

        netmask 255.255.255.0

        broadcast 192.168.1.255

        gateway 192.168.1.1

        bridge_ports eth1

        bridge_fd 9

        bridge_hello 2

        bridge_maxage 12

        bridge_stp off

  • Replace root with your username in above if required.

Restart network services

  $ sudo /etc/init.d/networking restart


Output of ip a:

root@SERVER:/etc/network# ip a

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 1a:43:5c:91:97:fa brd ff:ff:ff:ff:ff:ff
inet 62.212.75.244/27 brd 62.212.75.255 scope global eth0
inet6 fe80::1843:5cff:fe91:97fa/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP qlen 1000
link/ether e6:6b:86:f8:24:cb brd ff:ff:ff:ff:ff:ff
4: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
link/ether 92:09:ff:ee:2f:84 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.211/24 brd 192.168.1.255 scope global br0
inet6 fe80::e46b:86ff:fef8:24cb/64 scope link
valid_lft forever preferred_lft forever
5: tap0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast master br0 state DOWN qlen 500
link/ether 92:09:ff:ee:2f:84 brd ff:ff:ff:ff:ff:ff
inet 62.212.75.244/27 brd 62.212.75.255 scope global tap0
root@SERVER:/etc/network#

 

Output of /sbin/route -n:

Kernel IP routing table

root@SERVER:/etc/network# vi interfaces
root@SERVER:/etc/network# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 62.212.75.254 0.0.0.0 UG 0 0 0 eth0
62.212.75.224 0.0.0.0 255.255.255.224 U 0 0 0 eth0
62.212.75.224 0.0.0.0 255.255.255.224 U 0 0 0 tap0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 br0


Output of brctl show:

root@SERVER:/etc/network# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.9209ffee2f84 no eth1

  • Add tap0 interface to the bridge, using:

brctl addif br0 tap0

  • Verify the same with brctl show:

root@SERVER:/etc/network# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.9209ffee2f84 no eth1 tap0

 

Test

Ping gateway, Internet:

  ping -c3 192.168.1.1

  ping -c3 www.seimaxim.com

 
 

Was this answer helpful?

« Back