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