1 [[!meta title="bridging Ethernet segments using tinc under Linux"]]
3 ## Example: bridging Ethernet segments using tinc under Linux
5 Normally, in the default router mode, tinc will only tunnel IPv4 and IPv6
6 unicast packets. However, since 1.0pre5 there is an option to let the tinc
7 daemon act as a switch or a hub (using the Mode configuration variable). This
8 mode is necessary for tinc to pass non-IP based protocols (NetBEUI, AppleTalk,
9 IPX, etcetera), and to allow broadcast-based functionality in some applications
10 (Windows 'Network Neighborhood' without a WINS server, among others) to be
11 usable on a VPN created with tinc.
13 In switch and hub mode, broadcast packets are broadcast to other daemons and
14 (in switch mode) MAC addresses are dynamically learned from other tinc daemons
15 in order to route packets. With these mode tinc can be used to act as a bridge
16 between two or more Ethernet segments.
18 Bridging allows all nodes in the VPN to share the same subnet. However, if
19 this is the only reason for bridging, and you do not need to tunnel broadcast
20 or non-IP packets, you can alternatively use [[proxy ARP|examples/proxy-arp]]
25 The network setup is as follows:
27 * Internal network, on both sides, is 192.168.0.0/16
28 * The host's own IP address on the internal network is 192.168.10.20
30 The gateway of each segment has an external interface, eth0, and an internal
31 interface eth1. Furthermore a bridge interface will be created with name
32 "bridge", and the internal interface will be made a slave of this bridge. The
33 virtual network interface used by tinc will also be a slave. Configuration of
34 the kernel In addition to the standard kernel configuration described in the
35 Configuring the kernel section of the manual, a bridge device needs to be added
36 to your kernel configuration.
38 To add the bridge device to the Linux 2.4.0 and higher kernels, select the
39 option under 'Networking options' called 802.1d Ethernet Bridging. You may
40 either compile this option as a module or build it into the kernel.
41 Configuration of the interfaces Switch and hub modes require that both sides of
42 a tinc VPN be contained within the same subnet (in this example, the subnet is
43 192.168.0.0/16). This is no different from the configuration that would be
44 required if tinc was replaced with an actual switch or hub.
46 host# brctl addbr bridge
47 host# ifconfig bridge 192.168.10.20 netmask 255.255.0.0
49 host# ifconfig eth1 0.0.0.0
50 host# brctl addif bridge eth1
51 host# ifconfig eth1 up
56 bridge name bridge id STP enabled interfaces
57 bridge 8000.005004003002 yes eth1
61 eth0 Link encap:Ethernet HWaddr 00:20:30:40:50:60
62 inet addr:123.234.123.42 Bcast:123.234.123.255 Mask:255.255.255.0
63 UP BROADCAST RUNNING MTU:1500 Metric:1
66 eth1 Link encap:Ethernet HWaddr 00:11:22:33:44:55
67 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
70 lo Link encap:Local Loopback
71 inet addr:127.0.0.1 Mask:255.0.0.0
72 UP LOOPBACK RUNNING MTU:3856 Metric:1
75 bridge Link encap:Ethernet HWaddr 00:11:22:33:44:55
76 inet addr:192.168.10.20 Bcast:192.168.255.255 Mask:255.255.0.0
77 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
79 vpn Link encap:Ethernet HWaddr 00:11:22:33:44:55
80 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
84 Kernel IP routing table
85 Destination Gateway Genmask Flags Metric Ref Use Iface
86 123.234.123.0 * 255.255.255.0 U 0 0 0 eth0
87 192.168.0.0 * 255.255.0.0 U 0 0 0 bridge
88 default 123.234.123.1 0.0.0.0 UG 0 0 0 eth0
90 ### Configuration of tinc
92 Note that switch and hub mode do not utilize the Subnet variable in the host
93 files. Instead, any packet received by the bridge interface will be passed to
94 the TUN/TAP device for processing. If your tinc instance is running in hub
95 mode, all packets are forwarded to the remote tinc instance. In switch mode,
96 tinc maintains an ARP cache to determine whether any received packet should be
97 forwarded to the remote tinc instance.
99 host# cat /etc/tinc/vpn/tinc.conf
104 host# cat /etc/tinc/vpn/tinc-up
107 ifconfig $INTERFACE 0.0.0.0
108 brctl addif bridge $INTERFACE
109 ifconfig $INTERFACE up
111 host# ls /etc/tinc/vpn/hosts
112 segment1 segment2 ...
114 host# cat /etc/tinc/vpn/hosts/segment1
115 Address = 123.234.123.42
116 -----BEGIN RSA PUBLIC KEY-----
118 -----END RSA PUBLIC KEY-----
120 host# cat /etc/tinc/vpn/hosts/segment2
121 Address = 200.201.202.203
122 -----BEGIN RSA PUBLIC KEY-----
124 -----END RSA PUBLIC KEY-----
126 ### Additional Configuration
128 If the Ethernet interface added to the bridge was used for the default route,
129 you will need to re-add the default route.
131 If you want to be able to filter packets on your bridge interface, you will
132 need to a kernel with [ebtables](http://ebtables.sourceforge.net/) support.
133 More information For more information on Linux bridging, see the [bridge-utils
134 homepage](http://www.linuxfoundation.org/collaborate/workgroups/networking/bridge).