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