blob: 506dbe4fbc2be6cdba922cde5c96e30e1c9cfb17 [file] [log] [blame]
Charles Chan20fabfb2019-09-07 11:24:54 -07001DHCP Relay
2==========
Charles Chan9e5c6172019-09-07 11:24:54 -07003
4.. tip::
5 We strongly recommend you to setup DHCP relay and configure the hosts to **obtain address via DHCP**.
Charles Chan20fabfb2019-09-07 11:24:54 -07006 See `Alternative: Configure static IP`_ if you want to statically configure IP address on each host.
Charles Chan9e5c6172019-09-07 11:24:54 -07007
8
Charles Chan3e1ae932019-09-09 15:16:57 -07009Overview
10--------
11The DHCP relay app used in Trellis is an L3 relay.
12That is, it support relaying DHCP packets from/to a server that's not in the same subnet of the client.
13
14Here's a list of features supported:
15
16- DHCPv4 and DHCPv6
17- DHCP server directly attached to fabric leaves, or indirectly connected via upstream router
18- DHCP client directly attached to fabric leaves, or indirectly connected via `LDRA (Light-weight DHCP Relay Agent) <https://tools.ietf.org/html/rfc6221>`_
19- Multiple DHCP servers for HA
20
21.. note::
22 Please pay attention to the definition of **direct/indirect server/client**.
23 You will find them many times later in this section.
Charles Chan20fabfb2019-09-07 11:24:54 -070024
25Configure DHCP Relay
26--------------------
27
Charles Chan3e1ae932019-09-09 15:16:57 -070028Server directly connected to fabric
29^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30
31.. image:: ../images/config-dhcp.png
32
33In this case, the configuration involves first configuring the switch interface with the vlan/subnet the DHCP service is part of.
34For example, if I have a switch ``of:205`` with a DHCP server on port 24 on vlan 20, the port config looks like:
35
36.. code-block:: json
37
38 {
39 "ports": {
40 "of:0000000000000205/24" : {
41 "interfaces" : [ {
42 "name" : "dhcp-server-intf",
43 "ips" : [ "10.0.2.254/24", "2001:db8:1::254/64" ],
44 "vlan-tagged" : [ 20 ]
45 } ]
46 }
47 }
48 }
49
50A second part of the configuration for the DHCP relay app requires a json configuration under the key apps:
51
52.. code-block:: json
53
54 {
55 "apps" : {
56 "org.onosproject.dhcp-relay" : {
57 "default" : {
58 "dhcpServerConnectPoint": "of:0000000000000205/24",
59 "serverIps": ["10.0.2.253", "2001:db8:2::2"]
60 }
61 }
62 }
63 }
64
65Note that the dhcprelay app is configured with location of the DHCP server (the switch port to which it is connected to the fabric).
66It is also configured with the DHCP server IP, but it is no longer necessary to configure the MAC address of the server.
67ONOS will automatically learn the MAC and VLAN corresponding to the serverIP.
68
69
70Server reachable via external router
71^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
72In this case, it is actually the external router that is directly connected to the fabric.
73This external router is already configured in the ports section of network-config (for vRouter functionality).
74For example, if the external router is connected to switch of:205 on port 1
75
76.. code-block:: json
77
78 {
79 "ports": {
80 "of:0000000000000205/1" : {
81 "interfaces" : [ {
82 "ips" : [ "192.168.101.2/30", "2000::c0a8:6402/120" ],
83 "mac" : "a2:9b:32:9d:7f:b3",
84 "name" : "internet-router"
85 } ]
86 }
87 }
88 }
89
90As before the ``ips`` and ``mac`` configured on port 1, actually correspond to the addresses configured in Quagga.
91The app config in this case, includes an additional field necessary to inform the dhcp-relay app of the gatewayIP through which the DHCP server can be reached.
92
93.. code-block:: json
94
95 {
96 "apps" : {
97 "org.onosproject.dhcp-relay" : {
98 "default" : {
99 "dhcpServerConnectPoint": "of:0000000000000205/1",
100 "serverIps": ["10.0.2.253", "2001:db8:2::2"],
101 "gatewayIps": ["192.168.101.1", "1000::100:1"]
102 }
103 }
104 }
105 }
106
107.. note::
108 Note that the dhcpserverConnectPoint should now be the switchport to which the external router is connected to the fabric.
109
110Setup DHCP server
111-----------------
112
113Install DHCP server
114^^^^^^^^^^^^^^^^^^^
115Modern DHCP servers should support relayed DHCP request.
116However, the way to configure them are probably different case to case.
117Here we use **isc-dhcp-server** on Ubuntu as an example.
118To install the DHCP server, simply run:
119
120.. code-block:: console
121
122 $ sudo apt-get install isc-dhcp-server
123
124
125Configure DHCP Server
126^^^^^^^^^^^^^^^^^^^^^
127Two configuration files are required by DHCP server.
128
129First, we need to specify which network interface the DHCP server should listen on.
130To do that, we need to modify ``/etc/default/isc-dhcp-server`` and change the following line.
131
132.. code-block:: text
133
134 INTERFACES="eth1"
135
136Next, we need to specify the subnet we want to lease.
137To do that, we need to modify ``/etc/dhcp/dhcpd.conf`` and add the following lines.
138
139Note that the subnet of ``eth1`` needs to be included.
140Otherwise, the DHCP server will not listen to the interface even though we have specified that in ``/etc/default/isc-dhcp-server``.
141
142.. code-block:: text
143
144 subnet 10.0.1.0 netmask 255.255.255.0 {
145 range 10.0.1.1 10.0.1.240;
146 option routers 10.0.1.254;
147 }
148
149 # A subnet that matches the interface IP address is required by isc-dhcp-server
150 subnet 10.0.2.0 netmask 255.255.255.0 {
151 range 10.0.2.1 10.0.2.240;
152 option routers 10.0.2.254;
153 }
154
155It's similar to configure DHCPv6.
156
157.. code-block:: text
158
159 subnet6 2001:db8:1::/64 {
160 # Range for clients
161 range6 2001:db8:1::129 2001:db8:1::250;
162
163 # Range for clients requesting a temporary address
164 range6 2001:db8:1::/64 temporary;
165 }
166 # A subnet that matches the interface IP address is required by isc-dhcp-server
167 subnet6 2001:db8:2::/64 {
168 # Range for clients
169 range6 2001:db8:2::129 2001:db8:2::254;
170
171 # Range for clients requesting a temporary address
172 range6 2001:db8:2::/64 temporary;
173
174 # Prefix range for delegation to sub-routers
175 prefix6 2001:db8:1:: 2001:db8:10:: /56;
176
177 }
178
179Finally, restart the DHCP server.
180
181.. code-block:: console
182
183 $ sudo service isc-dhcp-server restart
184
185Testing
186-------
187The host should be able to obtain an IP address from the pool we specified.
188Try to run ``dhclient`` and see if the host can get an IP address.
189
190.. code-block:: console
191
192 sudo dhclient eth1
193
194It's similar to test DHCPv6
195
196.. code-block:: console
197
198 sudo dhclient -6 -N eth1 # for obtaining ip address
199 sudo dhclient -6 -P -N eth1 # for obtaining ip address and prefix together
200
201 sudo dhclient -6 -r eth1 # for releasing ip address
202 sudo dhclient -6 -P -r eth1 # for releasing prefix
203
204
205If something goes wrong, check ``/var/log/syslog`` for DHCP server log and run ``tcpdump`` on DHCP server to see if the DHCP packets from the host reach the server correctly.
206
207
208Additional Features
209-------------------
210
211DHCP Relay store
212^^^^^^^^^^^^^^^^
213DHCP relay application stores information from DHCP packet which processed by the app, administrator can use CLI command ``dhcp-relay`` to query these information.
214The store provides these functionality:
215
216- Latest state of DHCP client (e.g. client location, last seen time, DHCP type...), for debugging purpose
217- For direct host, ONOS can find location and vlan from relay agent option, however, for indirect host, ONOS need to query last state from the store to find correct destination.
218
219
220DHCPv6 Relay counter
221^^^^^^^^^^^^^^^^^^^^
222There are two DHCPv6 packet counters which are Host basis counters and Global counters.
223
224Host basis counters count and record DHCPv6 packets received on this host.
225It can be displayed by ``dhcp-relay counter``. These counters can be reset by typing ``dhcp-relay counter reset``.
226
227.. code-block:: console
228
229 onos> dhcp-relay counter
230 DHCP Relay Counters :
231 Counters for id=00:AA:BB:00:00:01/None, locations=[of:0000000000000204/3]
232 SOLICIT ............................ 4 packets
233 REQUEST ............................ 4 packets
234 ADVERTISE ............................ 4 packets
235 RENEW ............................ 1000 packets
236 REPLY ............................ 1004 packets
237 Counters for id=00:AA:00:00:00:01/None, locations=[of:0000000000000205/3][D]
238 SOLICIT ............................ 2 packets
239 REQUEST ............................ 2 packets
240 ADVERTISE ............................ 2 packets
241 RENEW ............................ 500 packets
242 CONFIRM ............................ 2 packets
243 REPLY ............................ 500 packets
244
245 onos> dhcp-relay counter reset
246
247Global counters counts and records all DHCPv6 packets received in ONOS.
248It can be displayed by ``dhcp-relay-agg-counters``. These counters can be reset by typing ``dhcp-relay-agg-counters reset``.
249
250.. code-block:: console
251
252 onos> dhcp-relay-agg-counters
253 DHCP Relay Aggregate Counters :
254 SOLICIT ............................ 12 packets
255 REQUEST ............................ 12 packets
256 ADVERTISE ............................ 12 packets
257 REBIND ............................ 4 packets
258 RENEW ............................ 3026 packets
259 CONFIRM ............................ 4 packets
260 REPLY ............................ 3044 packets
261
262 onos> dhcp-relay-agg-counters reset
263
264
265Indirect client support
266^^^^^^^^^^^^^^^^^^^^^^^
267DHCP relay can support hosts which do not directly connect to Trellis fabric.
268These hosts usually connected to another LDRA, the LDRA will forward DHCP packet to/from Trellis network.
269
270For **DHCPv4**, packets from the LDRA includes a valid DHCP relay agent option (option 82).
271DHCP Relay application checks relay agent option and determine the DHCP packet comes from direct or indirect host.
272
273.. image:: ../images/config-dhcp-indirect.jpg
274
275ONOS uses circuit id option in relay agent option with specific format if DHCP packet comes without relay agent option, the format of circuit will be: ``ConnectPoint:VlanId``
276For example, the DHCP request/discover packet comes from ``of:000000000000001/1`` with ``VLAN 100``, the circuit ONOS put will be ``of:000000000000001/1:100`` and send DHCP packet to DHCP server.
277Indirect host won't put into host store. DHCP relay app will put IP address of indirect host to the route store, and use IP address of relay agent as next hop.
278
279**DHCPv6** clients will be handled similar to DHCPv4.
280One major difference is that DHCPv6 supports ``RELAY-FORWARD`` message type and ``InterfaceId`` option natively, so we utilize those fields to encode information.
281
282
283Overwrite relay agent IP
284^^^^^^^^^^^^^^^^^^^^^^^^
285The DHCP relay can overwrite the relay agent address (``giaddr`` in **DHCPv4**, ``link-addr`` in **DHCPv6**) in DHCP message for different device.
286If ``relayAgentIps`` is configured, the app will overwrite ``giaddr`` or ``link-addr`` before it forward the DHCP message to the server.
287Otherwise, it will retain the original relay agent IP.
288An example configuration is shown below:
289
290.. code-block:: json
291
292 {
293 "apps" : {
294 "org.onosproject.dhcprelay" : {
295 "default": [{
296 "dhcpServerConnectPoint": "of:0000000000000002/2",
297 "serverIps": ["172.168.10.2", "2000::200:1"],
298 "gatewayIps": ["192.168.10.254", "1000::100:1"],
299 "relayAgentIps": {
300 "of:0000000000000001": {
301 "ipv4": "10.0.0.10",
302 "ipv6": "2000::10"
303 },
304 "of:0000000000000002": {
305 "ipv4": "10.0.1.10",
306 "ipv6": "2000::1:10"
307 }
308 }
309 }]
310 }
311 }
312 }
313
314
315Configure multiple servers
316^^^^^^^^^^^^^^^^^^^^^^^^^^
317DHCP server HA can be achieved by specifying additional server configuration objects.
318Client initiated packets like ``SOLICIT`` or ``REBIND`` shall be replicated and sent to all server objects.
319Below is an example of multiple server configuration:
320
321.. code-block:: json
322
323 {
324 "apps" : {
325 "org.onosproject.dhcprelay" : {
326 "default": [
327 {
328 "dhcpServerConnectPoint": "of:0000000000000205/5",
329 "serverIps": ["10.0.3.252", "2002:4::253"],
330 "gatewayIps": ["10.0.3.100","2001:3::100"],
331 "relayAgentIps": {
332 "of:0000000000000204": {
333 "ipv4": "10.0.2.254",
334 "ipv6": "2001:2::254"
335 }
336 }
337 },
338 {
339 "dhcpServerConnectPoint": "of:0000000000000206/3",
340 "serverIps": ["2002:5::253"],
341 "gatewayIps": ["2001:4::100"],
342 "relayAgentIps": {
343 "of:0000000000000204": {
344 "ipv4": "10.0.2.254",
345 "ipv6": "2001:2::254"
346 }
347 }
348 }
349 ],
350 "indirect": [
351 {
352 "dhcpServerConnectPoint": "of:0000000000000205/5",
353 "serverIps": ["10.0.3.252", "2002:4::253"],
354 "gatewayIps": ["10.0.3.100", "2001:3::100"],
355 "relayAgentIps": {
356 "of:0000000000000204": {
357 "ipv4": "10.0.2.254",
358 "ipv6": "2001:2::254"
359 }
360 }
361 },
362 {
363 "dhcpServerConnectPoint": "of:0000000000000205/5",
364 "serverIps": ["10.0.3.252", "2002:5::253"],
365 "gatewayIps": ["10.0.3.100", "2001:3::100"],
366 "relayAgentIps": {
367 "of:0000000000000204": {
368 "ipv4": "10.0.2.254",
369 "ipv6": "2001:2::254"
370 }
371 }
372 },
373 {
374 "dhcpServerConnectPoint": "of:0000000000000206/3",
375 "serverIps": ["2002:5::253"],
376 "gatewayIps": ["2001:4::100"],
377 "relayAgentIps": {
378 "of:0000000000000204": {
379 "ipv4": "10.0.2.254",
380 "ipv6": "2001:2::254"
381 }
382 }
383 },
384 {
385 "dhcpServerConnectPoint": "of:0000000000000206/3",
386 "serverIps": ["2002:4::253"],
387 "gatewayIps": ["2001:4::100"],
388 "relayAgentIps": {
389 "of:0000000000000204": {
390 "ipv4": "10.0.2.254",
391 "ipv6": "2001:2::254"
392 }
393 }
394 }
395 ]
396 }
397 }
398 }
399
400- ``dhcpServerConnectPoint``: represent the location of DHCP server
401- ``serverIps``: IP address of the DHCP server, contains at least one IP address of DHCP server.
402 IP address can be IPv4 or IPv6 for different version of DHCP.
403 Will use first address if multiple IPv4 or IPv6 address configured.
404- ``gatewayIps``: Optional. Should be configured if the DHCP server is not directly connected to the Trellis network
405 . It tells which gateway we need to send to reach the server.
406
407.. note::
408 - If ``indirect`` server configuration is not configured, the app will use ``default`` configuration for all cases.
409
410
411Ignoring DHCP relay on a particular VLAN
412^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
413In some cases, it may be necessary to avoid punting DHCP packets to the controller, and letting them be forwarded normally through the data plane.
414In such cases, the DHCP relay application can be configured to avoid punting DHCP packets on a particular VLAN on a particular switch.
415
416.. code-block:: json
417
418 {
419 "apps" : {
420 "org.onosproject.dhcprelay" : {
421 "ignoreDhcp" : [
422 { "deviceId": "of:0000000000000205", "vlan":24 },
423 { "deviceId": "of:0000000000000206", "vlan":24 }
424 ]
425 }
426 }
427 }
428
429In the example shown above, DHCP packets on vlan 24 are not punted to the controller from switches of:205 and of:206
430
431
432DHCPv6 Prefix Delegation (PD) Pushing
433^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
434
435.. note::
436 This feature requires both ``dhcprelay`` and ``fpm`` apps to be activated
437
438PD pushing allows IPv6 prefixes from DhcpRelay to be sent over the FPM connection to Quagga where they will be configured as a static route.
439Prior to PD Pushing, the FPM connection was only used by Quagga in one direction to push routes to FPM. PD pushing is disabled by default in DHCP Relay and FPM.
440
441To enable in DHCP relay:
442
443.. code-block:: console
444
445 onos> cfg set org.onosproject.dhcprelay.DhcpRelayManager DhcpFpmEnabled true
446
447To display PD's stored in dhcp relay, execute the following cli:
448
449.. code-block:: console
450
451 onos> dhcp-fpm-routes
452
453When PD pushing is enabled in FPM, by default the next-hop to be used for all prefixes pushed to Quagga will be retrieved from the first interface with ``RUR`` in the name in ONOS.
454Next-hop may also be configured using FPM component config. This will override a ``RUR`` interface if present.
455If there is no interface with ``RUR`` in the name and the next-hop is not configured, no prefixes can be pushed to Quagga even if PD pushing is enabled. For DhcpRelay, only the IPv6 next-hop is needed.
456
457To enable in FPM:
458
459.. code-block:: console
460
461 onos> cfg set org.onosproject.routing.fpm.FpmManager pdPushNextHopIPv4 124.200.1.60
462 onos> cfg set org.onosproject.routing.fpm.FpmManager pdPushNextHopIPv6 2001:a08::2
463 onos> cfg set org.onosproject.routing.fpm.FpmManager pdPushEnabled true
464
465
466To verify that PD pushing is enabled:
467
468.. code-block:: console
469
470 onos> fpm-connections
471 PD Pushing is enabled.
472 peer 124.200.3.42:48640 connected to 127.0.0.1 since 2m23s ago * (2 routes locally)
473
474
475Prefixes pushed to Quagga can be displayed in vtysh using ``show ip route`` and ``show ipv6 route``.
476If the output is not as expected, check the Quagga log to see if it was received from FPM.
477
478.. note::
479 Quagga requires a patch to be able to receive Netlink Messages from FPM.
480
481
482Clean up expired address and PD prefix
483^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
484DHCPv6 relay cleans up stale IP address and pd prefix based on timer whose default interval is 24 hours (24 * 3600 secs = 86400 secs).
485If the preferred life time of ip address or pd prefix exceeds 1/2 of poll interval, they will be removed from ONOS.
486The poll interval can be modified by ``cfg set org.onosproject.dhcprelay.DhcpRelayManager dhcpPollInterval <newVal>``
487
488.. code-block:: console
489
490 onos> cfg get org.onosproject.dhcprelay.DhcpRelayManager
491 org.onosproject.dhcprelay.DhcpRelayManager
492 name=dhcpPollInterval, type=integer, value=86400, defaultValue=86400, description=dhcp relay poll interval
493
494 onos> cfg set org.onosproject.dhcprelay.DhcpRelayManager dhcpPollInterval 60
495
496 onos> cfg get org.onosproject.dhcprelay.DhcpRelayManager
497 org.onosproject.dhcprelay.DhcpRelayManager
498 name=dhcpPollInterval, type=integer, value=60, defaultValue=86400, description=dhcp relay poll interval
499
Charles Chan20fabfb2019-09-07 11:24:54 -0700500
501Alternative: Configure static IP
502--------------------------------
Charles Chan9e5c6172019-09-07 11:24:54 -0700503Although we strongly recommend to use `DHCP Relay`_ for IP assignment,
504it is also possible to statically configure the IP address and route on the host.
505
5061. **Configure the IP address and subnet mask**
507
508 Make sure the IP address and the subnet mask on the fabric network interface of the host is consistent with
509 the information in the Network Configuration section. For example, you can run
510
511 .. code-block:: console
512
513 # ip addr add 10.0.0.1/24 dev mlx0
514
5152. **Configure the default route**
516
517 Make sure you change the default route of the host to the interface IP of the leaf switch it connects to.
518 For example, you can run
519
520 .. code-block:: console
521
522 # ip route add default via 10.0.0.254
523
524 .. note::
525 In the case that you want to keep default route through the management network,
526 you need to add routes to all other subnets in the network one by one.
527
5283. **Trigger host learning**
529
530 We need to let ONOS learn the host in order to program corresponding flows and groups.
531 This is automatically done as part of the DHCP process.
532 However, we need to manually triggers it by sending an ARP or ND packet if the host is configured to use static IP.
533
534 .. code-block:: console
535
536 # arping -c 1 ${GATEWAY_IP}
537
538 .. code-block:: console
539
540 # ndsend ${HOST_IP} ${INTF}
Charles Chan3e1ae932019-09-09 15:16:57 -0700541
542
543Reference
544---------
Charles Chand68eb662019-09-11 15:32:28 -0700545- https://www.cisco.com/c/en/us/support/docs/security/adaptive-security-appliance-asa-software/116265-configure-product-00.html