1 > # Company: PowerCraft Technology
2 > # Author: Copyright Jelle de Jong <jelledejong@powercraft.nl>
3 > # Note: Please send me an email if you enhanced the document
7 > # This document is free documentation; you can redistribute it and/or
8 > # modify it under the terms of the Creative Commons Attribution Share
9 > # Alike as published by the Creative Commons Foundation; either version
10 > # 3.0 of the License, or (at your option) any later version.
12 > # This document is distributed in the hope that it will be useful,
13 > # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 > # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 > # Creative Commons BY-SA License for more details.
17 > # http://creativecommons.org/licenses/by-sa/
19 > #-----------------------------------------------------------------------
21 > # for commercial support contact me, part of the revenue go back to tinc
23 > #-----------------------------------------------------------------------
25 > # http://www.tinc-vpn.org/
26 > # http://www.tinc-vpn.org/examples/bridging
27 > # http://www.tinc-vpn.org/documentation/tinc_toc
29 > #-----------------------------------------------------------------------
31 > # <@guus> Well all the tinc daemons together act like a single switcch
32 > # <@guus> And each node in the VPN is connected to a port of that switch
33 > # <@guus> And if you bridge the VPN interface with eth0, then it's like you plug a cable in a port of your eth0 LAN and the other end of that cable into the tinc switch
35 > #-----------------------------------------------------------------------
37 > unset LANG LANGUAGE LC_ALL
38 > apt-get update; apt-get dist-upgrade
41 > apt-get install tinc
42 > apt-get install bridge-utils
44 > #-----------------------------------------------------------------------
46 > /etc/init.d/tinc stop
48 > #-----------------------------------------------------------------------
50 > # ls -hal /dev/net/tun
51 > crw-rw-rw- 1 root root 10, 200 May 20 20:07 /dev/net/tun
53 > # grep tinc /etc/services
54 > tinc 655/tcp # tinc control port
57 > cat /usr/share/doc/tinc/README.Debian
58 > zcat /usr/share/doc/tinc/README.gz | less
59 > zcat /usr/share/doc/tinc/NEWS.gz | less
60 > cat /usr/share/doc/tinc/examples/tinc-up
61 > w3m /usr/share/doc/tinc/tinc_0.html
63 > cat /etc/default/tinc
64 > less /etc/init.d/tinc
66 > #-----------------------------------------------------------------------
68 > vim /etc/default/tinc
70 > cat /etc/default/tinc
72 > #-----------------------------------------------------------------------
74 > cat /etc/tinc/nets.boot
75 > echo 'powercraft01' | tee --append /etc/tinc/nets.boot
76 > cat /etc/tinc/nets.boot
78 > #-----------------------------------------------------------------------
80 > ls -hal /etc/tinc/scallab01/
81 > mkdir --verbose /etc/tinc/powercraft01/
82 > mkdir --verbose /etc/tinc/powercraft01/hosts/
83 > touch /etc/tinc/powercraft01/tinc.conf
85 > #-----------------------------------------------------------------------
87 > vim /etc/network/interfaces
89 > # tinc-vpn: dhcp bridge
91 > iface br0 inet static
93 > netmask 255.255.255.0
94 > # pre-up /sbin/ifconfig eth2 hw ether 00:1b:21:61:af:d7
95 > # pre-up /sbin/ifconfig eth2 0.0.0.0
101 > cat /etc/network/interfaces
103 > #-----------------------------------------------------------------------
105 > echo 'interface "br0" {
106 > request subnet-mask, broadcast-address, time-offset,
107 > host-name, netbios-scope, interface-mtu, ntp-servers;
108 > }' | tee --append /etc/dhcp3/dhclient.conf
110 > cat /etc/dhcp3/dhclient.conf
112 > #-----------------------------------------------------------------------
114 > vim /etc/dhcp3/dhcpd.conf
116 > subnet 192.168.3.0 netmask 255.255.255.0 {
117 > range 192.168.3.200 192.168.3.240;
118 > option routers 192.168.3.1;
119 > option domain-name-servers 192.168.3.1;
122 > #-----------------------------------------------------------------------
127 > #-----------------------------------------------------------------------
129 > vim /etc/default/dhcp3-server
130 > INTERFACES="vlan2 eth0 br0" # add the br0 to the correct location
132 > /etc/init.d/dhcp3-server restart
134 > tail -n 400 -f /var/log/syslog
136 > #-----------------------------------------------------------------------
142 > #-----------------------------------------------------------------------
145 > br0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
146 > inet addr:192.168.3.1 Bcast:192.168.3.255 Mask:255.255.255.0
147 > inet6 addr: fe80::dc56:d3ff:fe1a:31df/64 Scope:Link
148 > UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
149 > RX packets:12 errors:0 dropped:0 overruns:0 frame:0
150 > TX packets:14 errors:0 dropped:0 overruns:0 carrier:0
151 > collisions:0 txqueuelen:0
152 > RX bytes:2568 (2.5 KB) TX bytes:1536 (1.5 KB)
155 > Kernel IP routing table
156 > Destination Gateway Genmask Flags Metric Ref Use Iface
157 > 192.168.3.0 0.0.0.0 255.255.255.0 U 0 0 0 br0
158 > 192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 vlan2
159 > 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
160 > 84.245.3.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
161 > 0.0.0.0 84.245.3.1 0.0.0.0 UG 100 0 0 eth1
164 > bridge name bridge id STP enabled interfaces
165 > br0 8000.000000000000 no
167 > #-----------------------------------------------------------------------
169 > echo 'AddressFamily = ipv4
170 > Device = /dev/net/tun
173 > Name = server01' | tee /etc/tinc/powercraft01/tinc.conf
175 > cat /etc/tinc/powercraft01/tinc.conf
176 > chmod 640 /etc/tinc/powercraft01/tinc.conf
177 > ls -hal /etc/tinc/powercraft01/tinc.conf
180 > ifconfig $INTERFACE 0.0.0.0
181 > brctl addif br0 $INTERFACE' | tee /etc/tinc/powercraft01/tinc-up
183 > cat /etc/tinc/powercraft01/tinc-up
184 > chmod 750 /etc/tinc/powercraft01/tinc-up
185 > ls -hal /etc/tinc/powercraft01/tinc-up
188 > brctl delif br0 $INTERFACE
189 > ifconfig $INTERFACE down' | tee /etc/tinc/powercraft01/tinc-down
191 > cat /etc/tinc/powercraft01/tinc-down
192 > chmod 750 /etc/tinc/powercraft01/tinc-down
193 > ls -hal /etc/tinc/powercraft01/tinc-down
195 > #-----------------------------------------------------------------------
197 > rm /etc/tinc/powercraft01/rsa_key.priv
198 > rm /etc/tinc/powercraft01/hosts/server01
199 > tincd -n powercraft01 -K
201 > #-----------------------------------------------------------------------
203 > getent services | grep 656
205 > #-----------------------------------------------------------------------
207 > vim /etc/tinc/powercraft01/hosts/server01
209 > # add on head of file
212 > PMTUDiscovery = yes
215 > cat /etc/tinc/powercraft01/hosts/server01
217 > #-----------------------------------------------------------------------
219 > /etc/init.d/tinc stop
221 > /usr/sbin/tincd --net powercraft01 --no-detach --debug=5
223 > #-----------------------------------------------------------------------
225 > /etc/init.d/tinc restart
226 > tail --line=500 --follow /var/log/syslog
228 > #-----------------------------------------------------------------------
236 > #-----------------------------------------------------------------------
239 > br0 Link encap:Ethernet HWaddr 1e:eb:95:c3:04:d8
240 > inet addr:192.168.3.1 Bcast:192.168.3.255 Mask:255.255.255.0
241 > inet6 addr: fe80::dc56:d3ff:fe1a:31df/64 Scope:Link
242 > UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
243 > RX packets:17 errors:0 dropped:0 overruns:0 frame:0
244 > TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
245 > collisions:0 txqueuelen:0
246 > RX bytes:3328 (3.3 KB) TX bytes:2408 (2.4 KB)
249 > tun1 Link encap:Ethernet HWaddr 1e:eb:95:c3:04:d8
250 > inet6 addr: fe80::1ceb:95ff:fec3:4d8/64 Scope:Link
251 > UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
252 > RX packets:8 errors:0 dropped:0 overruns:0 frame:0
253 > TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
254 > collisions:0 txqueuelen:500
255 > RX bytes:2627 (2.6 KB) TX bytes:1340 (1.3 KB)
258 > Kernel IP routing table
259 > Destination Gateway Genmask Flags Metric Ref Use Iface
260 > 192.168.3.0 0.0.0.0 255.255.255.0 U 0 0 0 br0
261 > 192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 vlan2
262 > 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
263 > 84.245.3.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
264 > 0.0.0.0 84.245.3.1 0.0.0.0 UG 100 0 0 eth1
267 > bridge name bridge id STP enabled interfaces
268 > br0 8000.1eeb95c304d8 no tun1
270 > # brctl showmacs br0
271 > port no mac addr is local? ageing timer
272 > 1 1e:eb:95:c3:04:d8 yes 0.00
273 > 1 86:03:27:21:2e:60 no 44.19
275 > #-----------------------------------------------------------------------
277 > ps aux | grep tincd
278 > tincd -n powercraft01 -kUSR2
279 > tail -n 100 /var/log/syslog
281 > #-----------------------------------------------------------------------
283 > May 24 17:29:31 ashley tinc.powercraft01[11557]: Statistics for Linux tun/tap device (tap mode) /dev/net/tun:
284 > May 24 17:29:31 ashley tinc.powercraft01[11557]: total bytes in: 468
285 > May 24 17:29:31 ashley tinc.powercraft01[11557]: total bytes out: 0
286 > May 24 17:29:31 ashley tinc.powercraft01[11557]: Nodes:
287 > May 24 17:29:31 ashley tinc.powercraft01[11557]: server01 at MYSELF cipher 0 digest 0 maclength 0 compression 0 options 4 status 0018 nexthop server01 via server01 pmtu 1518 (min 0 max 1518)
288 > May 24 17:29:31 ashley tinc.powercraft01[11557]: End of nodes.
289 > May 24 17:29:31 ashley tinc.powercraft01[11557]: Edges:
290 > May 24 17:29:31 ashley tinc.powercraft01[11557]: End of edges.
291 > May 24 17:29:31 ashley tinc.powercraft01[11557]: Subnet list:
292 > May 24 17:29:31 ashley tinc.powercraft01[11557]: a2:63:0:96:a:c8#10 owner server01
293 > May 24 17:29:31 ashley tinc.powercraft01[11557]: End of subnet list.
295 > #-----------------------------------------------------------------------
297 > tcpdump -n -i br0 broadcast
298 > tcpdump -n -i tun0 broadcast
300 > #-----------------------------------------------------------------------
302 > tcpdump -n -e -i br0 icmp
303 > tcpdump -A -p -n -i br0 port 80
304 > tcpdump -A -p -n -i br0
306 > tcpdump -i br0 host 84.245.3.195 -l
308 > #-----------------------------------------------------------------------
310 > cat /var/lib/dhcp3/dhcpd.leases
312 > #-----------------------------------------------------------------------