Add a proxy ARP example.
[wiki] / examples / proxy-arp.mdwn
1 [[!meta title="proxy ARP as an alternative to bridging"]]
2
3 ## Example: proxy ARP as an alternative to bridging
4
5 If one wants to have a remote node appear to be on a local LAN (i.e., having an
6 IP address inside the local LAN's subnet), one can set up a bridge at the local
7 node, as described in the [[bridging example|examples/bridging]].  However,
8 setting up a bridge is rather complex, and if one only needs unicast IP traffic
9 to work, and broadcast or non-IP traffic is not a requirement, one can use the
10 [proxy ARP](http://en.wikipedia.org/wiki/Proxy_ARP) features of the operating
11 instead.
12
13 Since we only use unicast IP traffic, proxy ARP works with both router and
14 switch mode.
15
16 ### Overview
17
18 The network setup is as follows:
19
20 * Office LAN, the LAN on interface eth0 uses the range 192.168.1.0/24. The office node uses the address 192.168.1.2.
21 * Road warrior, using the address 192.168.1.123. 
22
23 ### Configuration of tinc at the office
24
25 >     host# cat /etc/tinc/vpn/tinc.conf
26 >     Name = office
27 >     #Optional:
28 >     #Mode = switch
29 >     
30 >     host# cat /etc/tinc/vpn/tinc-up
31 >     #!/bin/sh
32 >     
33 >     ifconfig $INTERFACE 192.168.1.2 netmask 255.255.255.255
34 >     route add 192.168.1.123 dev $INTERFACE
35 >     echo 1 >/proc/sys/net/ipv4/conf/eth0/proxy_arp
36 >     echo 1 >/proc/sys/net/ipv4/conf/$INTERFACE/proxy_arp
37 >     
38 >     host# ls /etc/tinc/vpn/hosts
39 >     office  roadwarrior  ...
40 >     
41 >     host# cat /etc/tinc/vpn/hosts/office
42 >     Address = 123.234.123.42
43 >     Subnet = 192.168.1.0/24
44 >     -----BEGIN RSA PUBLIC KEY-----
45 >     ...
46 >     -----END RSA PUBLIC KEY-----
47 >     
48 >     host# cat /etc/tinc/vpn/hosts/roadwarrior
49 >     Subnet = 192.168.1.123
50 >     -----BEGIN RSA PUBLIC KEY-----
51 >     ...
52 >     -----END RSA PUBLIC KEY-----
53
54 ### Configuration of tinc at the road warrior
55
56 >     host# cat /etc/tinc/vpn/tinc.conf
57 >     Name = roadwarrior
58 >     #Optional:
59 >     #Mode = switch
60 >     
61 >     host# cat /etc/tinc/vpn/tinc-up
62 >     #!/bin/sh
63 >     
64 >     ifconfig $INTERFACE 192.168.1.123 netmask 255.255.255.0
65
66 The host config files are, of course, identical to those on the office node.
67
68 ### Automatically adding routes
69
70 In the above configuration, the `tinc-up` script of the office node has a route
71 to the roadwarrior's address hardcoded.  To have tinc automatically add the
72 necessary routes, remove the `route add` command from the `tinc-up` script, and
73 instead add this `subnet-up` script:
74
75 >     host# cat /etc/tinc/vpn/subnet-up
76 >     #!/bin/sh
77 >     [ "$NAME" = "$NODE" ] && exit 0
78 >     ip route replace $SUBNET dev $INTERFACE