dellemc.enterprise_sonic.sonic_dhcp_relay module – Manage DHCP and DHCPv6 relay configurations on SONiC
Note
This module is part of the dellemc.enterprise_sonic collection (version 2.2.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install dellemc.enterprise_sonic
.
To use it in a playbook, specify: dellemc.enterprise_sonic.sonic_dhcp_relay
.
New in dellemc.enterprise_sonic 2.1.0
Synopsis
This module provides configuration management of DHCP and DHCPv6 relay parameters on Layer 3 interfaces of devices running SONiC.
Layer 3 interface and VRF name need to be created earlier in the device.
Parameters
Parameter |
Comments |
---|---|
Specifies the DHCP and DHCPv6 relay configurations. |
|
DHCP relay configurations to be set for the interface mentioned in name option. |
|
Specifies the DHCP relay circuit-id format.
Choices:
|
|
Enable link selection suboption. Choices:
|
|
Specifies the maximum hop count for DHCP relay packets. The range is from 1 to 16. |
|
Specifies the policy for handling of DHCP relay options. Choices:
|
|
List of DHCP server IPv4 addresses. |
|
IPv4 address of the DHCP server. |
|
Specifies the DHCP relay source interface. |
|
Specifies name of the VRF in which the DHCP server resides. This option is not used with state deleted. |
|
Enable VRF selection suboption. Choices:
|
|
DHCPv6 relay configurations to be set for the interface mentioned in name option. |
|
Specifies the maximum hop count for DHCPv6 relay packets. The range is from 1 to 16. |
|
List of DHCPv6 server IPv6 addresses. |
|
IPv6 address of the DHCPv6 server. |
|
Specifies the DHCPv6 relay source interface. |
|
Specifies name of the VRF in which the DHCPv6 server resides. This option is used only with state merged. |
|
Enable VRF selection suboption. Choices:
|
|
Full name of the Layer 3 interface, i.e. Eth1/1. |
|
The state of the configuration after module completion.
Choices:
|
Examples
# Using deleted
#
# Before State:
# -------------
#
# sonic# show running-configuration interface
# !
# interface Eth1/1
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 81.1.1.1/24
# ip dhcp-relay 91.1.1.1 92.1.1.1 vrf VrfReg1
# ip dhcp-relay max-hop-count 5
# ip dhcp-relay vrf-select
# ip dhcp-relay policy-action append
# ipv6 address 81::1/24
# ipv6 dhcp-relay 91::1 92::1
# ipv6 dhcp-relay max-hop-count 5
# !
# interface Eth1/2
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 61.1.1.1/24
# ip dhcp-relay 71.1.1.1 72.1.1.1 73.1.1.1
# ip dhcp-relay source-interface Vlan100
# ip dhcp-relay link-select
# ip dhcp-relay circuit-id %h:%p
# !
- name: Delete DHCP and DHCPv6 relay configurations
dellemc.enterprise_sonic.sonic_dhcp_relay:
config:
- name: 'Eth1/1'
ipv4:
server_addresses:
- address: '92.1.1.1'
vrf_select: true
max_hop_count: 5
ipv6:
server_addresses:
- address: '91::1'
- address: '92::1'
- name: 'Eth1/2'
ipv4:
server_addresses:
- address: '71.1.1.1'
- address: '72.1.1.1'
source_interface: 'Vlan100'
link_select: true
circuit_id: '%h:%p'
state: deleted
# After State:
# ------------
#
# sonic# show running-configuration interface
# !
# interface Eth1/1
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 81.1.1.1/24
# ip dhcp-relay 91.1.1.1 vrf VrfReg1
# ip dhcp-relay policy-action append
# ipv6 address 81::1/24
# !
# interface Eth1/2
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 61.1.1.1/24
# ip dhcp-relay 73.1.1.1
# !
# Using deleted
#
# NOTE: Support is provided in the dhcp_relay resource module for deletion of all attributes for a
# given address family (IPv4 or IPv6) by using a "special" YAML sequence specifying a server address list
# containing a single "blank" IP address under the target address family. The following example shows
# a task using this syntax for deletion of all DHCP (IPv4) configurations for an interface, but the
# equivalent syntax is supported for DHCPv6 (IPv6) as well.
#
# Before State:
# -------------
#
# sonic# show running-configuration interface
# !
# interface Eth1/1
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 81.1.1.1/24
# ip dhcp-relay 91.1.1.1 92.1.1.1 vrf VrfReg1
# ip dhcp-relay max-hop-count 5
# ip dhcp-relay vrf-select
# ip dhcp-relay policy-action append
# ipv6 address 81::1/24
# ipv6 dhcp-relay 91::1 92::1
# ipv6 dhcp-relay max-hop-count 5
# !
# interface Eth1/2
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 61.1.1.1/24
# ip dhcp-relay 71.1.1.1 72.1.1.1 73.1.1.1
# ip dhcp-relay source-interface Vlan100
# ip dhcp-relay link-select
# ip dhcp-relay circuit-id %h:%p
# !
- name: Delete all IPv4 DHCP relay configurations for interface Eth1/1
dellemc.enterprise_sonic.sonic_dhcp_relay:
config:
- name: 'Eth1/1'
ipv4:
server_addresses:
- address:
state: deleted
# After State:
# ------------
#
# sonic# show running-configuration interface
# !
# interface Eth1/1
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 81.1.1.1/24
# ipv6 address 81::1/24
# ipv6 dhcp-relay 91::1 92::1
# ipv6 dhcp-relay max-hop-count 5
# !
# interface Eth1/2
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 61.1.1.1/24
# ip dhcp-relay 71.1.1.1 72.1.1.1 73.1.1.1
# ip dhcp-relay source-interface Vlan100
# ip dhcp-relay link-select
# ip dhcp-relay circuit-id %h:%p
# !
# Using deleted
#
# Before State:
# -------------
#
# sonic# show running-configuration interface
# !
# interface Eth1/1
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 81.1.1.1/24
# ip dhcp-relay 91.1.1.1 92.1.1.1 vrf VrfReg1
# ip dhcp-relay max-hop-count 5
# ip dhcp-relay vrf-select
# ip dhcp-relay policy-action append
# ipv6 address 81::1/24
# ipv6 dhcp-relay 91::1 92::1
# ipv6 dhcp-relay max-hop-count 5
# !
# interface Eth1/2
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 61.1.1.1/24
# ip dhcp-relay 71.1.1.1 72.1.1.1 73.1.1.1
# ip dhcp-relay source-interface Vlan100
# ip dhcp-relay link-select
# ip dhcp-relay circuit-id %h:%p
# !
- name: Delete all DHCP and DHCPv6 relay configurations for interface Eth1/1
dellemc.enterprise_sonic.sonic_dhcp_relay:
config:
- name: 'Eth1/1'
state: deleted
# After State:
# ------------
#
# sonic# show running-configuration interface
# !
# interface Eth1/1
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 81.1.1.1/24
# ipv6 address 81::1/24
# !
# interface Eth1/2
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 61.1.1.1/24
# ip dhcp-relay 71.1.1.1 72.1.1.1 73.1.1.1
# ip dhcp-relay source-interface Vlan100
# ip dhcp-relay link-select
# ip dhcp-relay circuit-id %h:%p
# !
# Using deleted
#
# Before State:
# -------------
#
# sonic# show running-configuration interface
# !
# interface Eth1/1
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 81.1.1.1/24
# ip dhcp-relay 91.1.1.1 92.1.1.1 vrf VrfReg1
# ip dhcp-relay max-hop-count 5
# ip dhcp-relay vrf-select
# ip dhcp-relay policy-action append
# ipv6 address 81::1/24
# ipv6 dhcp-relay 91::1 92::1
# ipv6 dhcp-relay max-hop-count 5
# !
# interface Eth1/2
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 61.1.1.1/24
# ip dhcp-relay 71.1.1.1 72.1.1.1 73.1.1.1
# ip dhcp-relay source-interface Vlan100
# ip dhcp-relay link-select
# ip dhcp-relay circuit-id %h:%p
# !
- name: Delete all DHCP and DHCPv6 relay configurations
dellemc.enterprise_sonic.sonic_dhcp_relay:
config:
state: deleted
# After State:
# ------------
#
# sonic# show running-configuration interface
# !
# interface Eth1/1
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 81.1.1.1/24
# ipv6 address 81::1/24
# !
# interface Eth1/2
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 61.1.1.1/24
# !
# Using merged
#
# Before State:
# -------------
#
# sonic# show running-configuration interface
# !
# interface Eth1/1
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 81.1.1.1/24
# ipv6 address 81::1/24
# !
# interface Eth1/2
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 61.1.1.1/24
# ip dhcp-relay 71.1.1.1 72.1.1.1
# !
- name: Add DHCP and DHCPv6 relay configurations
dellemc.enterprise_sonic.sonic_dhcp_relay:
config:
- name: 'Eth1/1'
ipv4:
server_addresses:
- address: '91.1.1.1'
- address: '92.1.1.1'
vrf_name: 'VrfReg1'
vrf_select: true
max_hop_count: 5
policy_action: 'append'
ipv6:
server_addresses:
- address: '91::1'
- address: '92::1'
max_hop_count: 5
- name: 'Eth1/2'
ipv4:
server_addresses:
- address: '73.1.1.1'
source_interface: 'Vlan100'
link_select: true
circuit_id: '%h:%p'
state: merged
# After State:
# ------------
#
# sonic# show running-configuration interface
# !
# interface Eth1/1
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 81.1.1.1/24
# ip dhcp-relay 91.1.1.1 92.1.1.1 vrf VrfReg1
# ip dhcp-relay max-hop-count 5
# ip dhcp-relay vrf-select
# ip dhcp-relay policy-action append
# ipv6 address 81::1/24
# ipv6 dhcp-relay 91::1 92::1
# ipv6 dhcp-relay max-hop-count 5
# !
# interface Eth1/2
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 61.1.1.1/24
# ip dhcp-relay 71.1.1.1 72.1.1.1 73.1.1.1
# ip dhcp-relay source-interface Vlan100
# ip dhcp-relay link-select
# ip dhcp-relay circuit-id %h:%p
# !
# Using replaced
#
# Before State:
# -------------
#
# sonic# show running-configuration interface
# !
# interface Eth1/1
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 81.1.1.1/24
# ip dhcp-relay 91.1.1.1 92.1.1.1 vrf VrfReg1
# ip dhcp-relay max-hop-count 5
# ip dhcp-relay vrf-select
# ip dhcp-relay policy-action append
# ipv6 address 81::1/24
# ipv6 dhcp-relay 91::1 92::1
# ipv6 dhcp-relay max-hop-count 5
# !
# interface Eth1/2
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 61.1.1.1/24
# ip dhcp-relay 71.1.1.1 72.1.1.1 73.1.1.1
# ip dhcp-relay source-interface Vlan100
# ip dhcp-relay link-select
# ip dhcp-relay circuit-id %h:%p
# ipv6 address 61::1/24
# ipv6 dhcp-relay 71::1 72::1
# !
# interface Eth1/3
# mtu 9100
# speed 400000
# fec RS
# shutdown
# ip address 41.1.1.1/24
# ip dhcp-relay 51.1.1.1 52.1.1.1
# ip dhcp-relay circuit-id %h:%p
# ipv6 address 41::1/24
# ipv6 dhcp-relay 51::1 52::1
# !
- name: Replace DHCP and DHCPv6 relay configurations of specified interfaces
dellemc.enterprise_sonic.sonic_dhcp_relay:
config:
- name: 'Eth1/1'
ipv4:
server_addresses:
- address: '91.1.1.1'
- address: '93.1.1.1'
- address: '95.1.1.1'
vrf_name: 'VrfReg1'
vrf_select: true
ipv6:
server_addresses:
- address: '93::1'
- address: '94::1'
source_interface: 'Vlan100'
- name: 'Eth1/2'
ipv4:
server_addresses:
- address: '73.1.1.1'
circuit_id: '%h:%p'
state: replaced
# After State:
# ------------
#
# sonic# show running-configuration interface
# !
# interface Eth1/1
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 81.1.1.1/24
# ip dhcp-relay 91.1.1.1 93.1.1.1 95.1.1.1 vrf VrfReg1
# ip dhcp-relay vrf-select
# ipv6 address 81::1/24
# ipv6 dhcp-relay 93::1 94::1
# ipv6 dhcp-relay source-interface Vlan100
# !
# interface Eth1/2
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 61.1.1.1/24
# ip dhcp-relay 73.1.1.1
# ip dhcp-relay circuit-id %h:%p
# ipv6 address 61::1/24
# !
# interface Eth1/3
# mtu 9100
# speed 400000
# fec RS
# shutdown
# ip address 41.1.1.1/24
# ip dhcp-relay 51.1.1.1 52.1.1.1
# ip dhcp-relay circuit-id %h:%p
# ipv6 address 41::1/24
# ipv6 dhcp-relay 51::1 52::1
# !
# Using overridden
#
# Before State:
# -------------
#
# sonic# show running-configuration interface
# !
# interface Eth1/1
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 81.1.1.1/24
# ip dhcp-relay 91.1.1.1 92.1.1.1 vrf VrfReg1
# ip dhcp-relay max-hop-count 5
# ip dhcp-relay vrf-select
# ip dhcp-relay policy-action append
# ipv6 address 81::1/24
# ipv6 dhcp-relay 91::1 92::1
# ipv6 dhcp-relay max-hop-count 5
# !
# interface Eth1/2
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 61.1.1.1/24
# ip dhcp-relay 71.1.1.1 72.1.1.1 73.1.1.1
# ip dhcp-relay source-interface Vlan100
# ip dhcp-relay link-select
# ip dhcp-relay circuit-id %h:%p
# ipv6 address 61::1/24
# ipv6 dhcp-relay 71::1 72::1
# !
# interface Eth1/3
# mtu 9100
# speed 400000
# fec RS
# shutdown
# ip address 41.1.1.1/24
# ip dhcp-relay 51.1.1.1 52.1.1.1
# ip dhcp-relay circuit-id %h:%p
# ipv6 address 41::1/24
# ipv6 dhcp-relay 51::1 52::1
# !
- name: Override DHCP and DHCPv6 relay configurations
dellemc.enterprise_sonic.sonic_dhcp_relay:
config:
- name: 'Eth1/1'
ipv4:
server_addresses:
- address: '91.1.1.1'
- address: '93.1.1.1'
- address: '95.1.1.1'
vrf_name: 'VrfReg1'
vrf_select: true
ipv6:
server_addresses:
- address: '93::1'
- address: '94::1'
source_interface: 'Vlan100'
- name: 'Eth1/2'
ipv4:
server_addresses:
- address: '73.1.1.1'
circuit_id: '%h:%p'
state: overridden
# After State:
# ------------
#
# sonic# show running-configuration interface
# !
# interface Eth1/1
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 81.1.1.1/24
# ip dhcp-relay 91.1.1.1 93.1.1.1 95.1.1.1 vrf VrfReg1
# ip dhcp-relay vrf-select
# ipv6 address 81::1/24
# ipv6 dhcp-relay 93::1 94::1
# ipv6 dhcp-relay source-interface Vlan100
# !
# interface Eth1/2
# mtu 9100
# speed 400000
# fec RS
# no shutdown
# ip address 61.1.1.1/24
# ip dhcp-relay 73.1.1.1
# ip dhcp-relay circuit-id %h:%p
# ipv6 address 61::1/24
# !
# interface Eth1/3
# mtu 9100
# speed 400000
# fec RS
# shutdown
# ip address 41.1.1.1/24
# ipv6 address 41::1/24
# !
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The resulting configuration model invocation. Returned: when changed Sample: |
|
The configuration prior to the model invocation. Returned: always Sample: |
|
The set of commands pushed to the remote device. Returned: always Sample: |