blob: 569b3f4463229aff14c6705d585c8c2184b0e059 [file] [log] [blame]
Timo Teräsdafa05e2017-01-19 17:27:01 +02001Quagga / NHRP Design and Configuration Notes
2============================================
3
4Quagga/NHRP is an NHRP (RFC2332) implementation for Linux. The primary
5use case is to implement DMVPN. The aim is thus to be compatible with
6Cisco DMVPN (and potentially with FlexVPN in the future).
7
8
9Current Status
10--------------
11
12- IPsec integration with strongSwan (requires patched strongSwan)
13- IPv4 over IPv4 NBMA GRE
14- IPv6 over IPv4 NBMA GRE -- majority of code exist; but is not tested
15- Spoke (NHC) functionality complete
16- Hub (NHS) functionality complete
17- Multicast support is not done yet
18 (so OSPF will not work, use BGP for now)
19
20The code is not (yet) compatible with Cisco FlexVPN style DMVPN. It
21would require relaying IKEv2 routing messages from strongSwan to nhrpd
22and parsing that. It is doable, but not implemented for the time being.
23
24
25Routing Design
26--------------
27
28In contrast to opennhrp routing design, Quagga/NHRP routes each NHRP
29domain address individually (similar to Cisco FlexVPN).
30
31To create NBMA GRE tunnel you might use following:
32 ip tunnel add gre1 mode gre key 42 ttl 64 dev eth0
33 ip addr add 10.255.255.2/32 dev gre1
34 ip link set gre1 up
35
36This has two important differences compared to opennhrp setup:
37 1. The 'tunnel add' now specifies physical device binding. Quagga/NHRP
38 wants to know stable protocol address to NBMA address mapping. Thus,
39 add 'dev <physdev>' binding, or specify 'local <nbma-address>'. If
40 neither of this is specified, NHRP will not be enabled on the interface.
41 Alternatively you can skip 'dev' binding on tunnel if you allow
42 nhrpd to manage it using 'tunnel source' command (see below).
43
44 2. The 'addr add' now has host prefix. In opennhrp you would have used
45 the GRE subnet prefix length here instead, e.g. /24.
46
47Quagga/NHRP will automatically create additional host routes pointing to
48gre1 when a connection with these hosts is established. The gre1 subnet
49should be announced by routing protocol. This allows routing protocol
50to decide which is the closest hub and get the gre addresses' traffic.
51
52The second benefit is that hubs can then easily exchange host prefixes
53of directly connected gre addresses. And thus routing of gre addresses
54inside hubs is based on routing protocol's shortest path choice -- not
55on random choice from next hop server list.
56
57
58Configuring nhrpd
59-----------------
60
61The configuration is done using vtysh, and most commands do what they
62do in Cisco. As minimal configuration example one can do:
63 configure terminal
64 interface gre1
65 tunnel protection vici profile dmvpn
66 tunnel source eth0
67 ip nhrp network-id 1
68 ip nhrp shortcut
69 ip nhrp registration no-unique
70 ip nhrp nhs dynamic nbma hubs.example.com
71
72There's important notes about the "ip nhrp nhs" command:
73
74 1. The 'dynamic' works only against Cisco (or nhrpd), but is not
75 compatible with opennhrp. To use dynamic detection of opennhrp hub's
76 protocol address use the GRE broadcast address there. For the above
77 example of 10.255.255.0/24 the configuration should read instead:
78 ip nhrp nhs 10.255.255.255 nbma hubs.example.com
79
80 2. nbma <FQDN> works like opennhrp dynamic-map. That is, all of the
81 A-records are configured as NBMA addresses of different hubs, and
82 each hub protocol address will be dynamically detected.
83
84
85Hub functionality
86-----------------
87
88Sending Traffic Indication (redirect) notifications is now accomplished
89using NFLOG.
90
91Use:
92iptables -A FORWARD -i gre1 -o gre1 \
93 -m hashlimit --hashlimit-upto 4/minute --hashlimit-burst 1 \
94 --hashlimit-mode srcip,dstip --hashlimit-srcmask 16 --hashlimit-dstmask 16 \
95 --hashlimit-name loglimit-0 -j NFLOG --nflog-group 1 --nflog-range 128
96
97or similar to get rate-limited samples of the packets that match traffic
98flow needing redirection. This kernel NFLOG target's nflog-group is configured
99in global nhrp config with:
100 nhrp nflog-group 1
101
102To start sending these traffic notices out from hubs, use the nhrp per-interface
103directive:
104 ip nhrp redirect
105
106opennhrp used PF_PACKET and tried to create packet filter to get only
107the packets of interest. Though, this was bad if shortcut fails to
108establish (remote policy, or both are behind NAT or restrictive
109firewalls), all of the relayaed traffic would match always.
110
111
112Getting information via vtysh
113-----------------------------
114
115Some commands of interest:
116 - show dmvpn
117 - show ip nhrp cache
118 - show ip nhrp shortcut
119 - show ip route nhrp
120 - clear ip nhrp cache
121 - clear ip nhrp shortcut
122
123
124Integration with strongSwan
125---------------------------
126
127Contrary to opennhrp, Quagga/NHRP has tight integration with IKE daemon.
128Currently strongSwan is supported using the VICI protocol. strongSwan
129is connected using UNIX socket (hardcoded now as /var/run/charon.vici).
130Thus nhrpd needs to be run as user that can open that file.
131
132Currently, you will need patched strongSwan. The working tree is at:
133 http://git.alpinelinux.org/cgit/user/tteras/strongswan/log/?h=tteras
134
135And the branch with patches against latest release are:
136 http://git.alpinelinux.org/cgit/user/tteras/strongswan/log/?h=tteras-release
137