diff --git a/doc/Command-Reference.md b/doc/Command-Reference.md index 35d7b28aef79..26b23ac31c91 100644 --- a/doc/Command-Reference.md +++ b/doc/Command-Reference.md @@ -2231,27 +2231,32 @@ This sub-section of commands is used to add or remove the DHCP Relay Destination **config vlan dhcp_relay add** -This command is used to add a DHCP Relay Destination IP address to the a VLAN. Note that more that one DHCP Relay Destination IP address can be added on a VLAN interface. +This command is used to add a DHCP Relay Destination IP address or multiple IP addresses to a VLAN. Note that more than one DHCP Relay Destination IP address can be added on a VLAN interface. - Usage: ``` - config vlan dhcp_relay add + config vlan dhcp_relay add ``` - Example: ``` admin@sonic:~$ sudo config vlan dhcp_relay add 1000 7.7.7.7 - Added DHCP relay destination address 7.7.7.7 to Vlan1000 + Added DHCP relay destination address ['7.7.7.7'] to Vlan1000 + Restarting DHCP relay service... + ``` + ``` + admin@sonic:~$ sudo config vlan dhcp_relay add 1000 7.7.7.7 1.1.1.1 + Added DHCP relay destination address ['7.7.7.7', '1.1.1.1'] to Vlan1000 Restarting DHCP relay service... ``` **config vlan dhcp_relay delete** -This command is used to delete a configured DHCP Relay Destination IP address from a VLAN interface. +This command is used to delete a configured DHCP Relay Destination IP address or multiple IP addresses from a VLAN interface. - Usage: ``` - config vlan dhcp_relay del + config vlan dhcp_relay del ``` - Example: @@ -2260,6 +2265,11 @@ This command is used to delete a configured DHCP Relay Destination IP address fr Removed DHCP relay destination address 7.7.7.7 from Vlan1000 Restarting DHCP relay service... ``` + ``` + admin@sonic:~$ sudo config vlan dhcp_relay del 1000 7.7.7.7 1.1.1.1 + Removed DHCP relay destination address ('7.7.7.7', '1.1.1.1') from Vlan1000 + Restarting DHCP relay service... + ``` Go Back To [Beginning of the document](#) or [Beginning of this section](#dhcp-relay) diff --git a/utilities_common/cli.py b/utilities_common/cli.py index 59aa36a7c054..9c0d0afe6771 100644 --- a/utilities_common/cli.py +++ b/utilities_common/cli.py @@ -7,6 +7,7 @@ import click import json +import netaddr from natsort import natsorted from sonic_py_common import multi_asic @@ -203,6 +204,17 @@ def is_ipaddress(val): return False return True +def ipaddress_type(val): + """ Return the IP address type """ + if not val: + return None + + try: + ip_version = netaddr.IPAddress(str(val)) + except netaddr.core.AddrFormatError: + return None + + return ip_version.version def is_ip_prefix_in_key(key): '''