Configuring and Disabling DHCPv4 Relay

You can configure the device to run a DHCP relay agent, which forwards DHCP packets between clients and servers. This feature is useful when clients and servers are not on the same physical subnet. Relay agents receive DHCP messages and then generate a new DHCP message to send out on another interface. The relay agent sets the gateway address (giaddr field of the DHCP packet) and, if configured, adds the relay agent information option (Option 82) in the packet and forwards it to the DHCP server. The reply from the server is forwarded back to the client after removing Option 82. After you enable Option 82, the device uses the binary ifindex format by default. If needed, you can change the Option 82 setting to use an encoded string format instead.

Note When the device relays a DHCP request that already includes Option 82 information, the device forwards the request with the original Option 82 information without altering it.

This section contains payload examples and CLIs to demonstrate how to use the NX-API REST API to configure DHCPv4 relay on Cisco Nexus 3000 and 9000 Series switches and to show how the REST APIs correspond to the CLI commands. For more information, see the Cisco Nexus 9000 Series NX-OS Security Configuration Guide, Release 7.x.

https://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-installation-and-configuration-guides-list.html/

Configuring DHCPv4 Relay

Configuring DHCPv4 Relay
POST http://<IP_Address>/api/mo/sys/dhcp.json
{
"dhcpEntity": {
  "children": [
    {
      "dhcpInst": {
        "attributes": {
          "v4RelayEnabled": "yes"
}}}]}}
{
    imdata:[]
}
<System>
  <dhcp-items>
    <inst-items>
      <v4RelayEnabled>true</v4RelayEnabled>
    </inst-items>
  </dhcp-items>
</System>

Enables DHCPv4 and disables DHCPv6.


CLI Commands

The CLI commands and options listed below are the equivalent to the payload example displayed in the pane on the right.

ip dhcp relay

For other CLI options, see the Cisco Nexus 9000 Series NX-OS Command Reference: http://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-command-reference-list.html

See the NX-API DME Model Reference for detailed information about classes and attributes described in the payload: https://developer.cisco.com/site/nx-os/docs/nexus-model-reference/

For information about using the payloads, see the Cisco Nexus 9000 Series NX-OS Programmability Guide https://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-programming-reference-guides-list.html

Disabling DHCPv4 Relay

Disabling DHCPv4 Relay
POST http://<IP_Address>/api/mo/sys/dhcp.json
{
"dhcpEntity": {
  "children": [
    {
      "dhcpInst": {
        "attributes": {
          "v4RelayEnabled": "no"
}}}]}}
{
    imdata:[]
}
<System>
  <dhcp-items>
    <inst-items>
      <v4RelayEnabled>false</v4RelayEnabled>
    </inst-items>
  </dhcp-items>
</System>


CLI Commands

The CLI commands and options listed below are the equivalent to the payload example displayed in the pane on the right.

no ip dhcp relay

For other CLI options, see the Cisco Nexus 9000 Series NX-OS Command Reference: http://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-command-reference-list.html

See the NX-API DME Model Reference for detailed information about classes and attributes described in the payload: https://developer.cisco.com/site/nx-os/docs/nexus-model-reference/

For information about using the payloads, see the Cisco Nexus 9000 Series NX-OS Programmability Guide https://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-programming-reference-guides-list.html

Configuring an IP Address for a DHCP Server

Configuring an IP Address for a DHCP Server
POST http://<IP_Address>/api/mo/sys/dhcp/inst.json
{
  "dhcpInst": {
    "children": [
      {
        "dhcpRelayIf": {
          "attributes": {
            "id": "eth1/1"
          },
          "children": [
            {
              "dhcpRelayAddr": {
                "attributes": {
                  "address": "128.66.0.0",
                  "counter": "2",
                  "vrf": "!unspecified"
}}}]}}]}}
{
    imdata:[]
}
<System>
  <dhcp-items>
    <inst-items>
      <relayif-items>
        <RelayIf-list>
          <id>eth1/1</id>
          <addr-items>
            <RelayAddr-list>
              <vrf>!unspecified</vrf>
              <address>128.66.0.0</address>
              <counter>2</counter>
            </RelayAddr-list>
          </addr-items>
        </RelayIf-list>
      </relayif-items>
    </inst-items>
  </dhcp-items>
</System>

Configures an IP address for a DHCP server to which the relay agent forwards BOOTREQUEST packets received on this interface.

This configuration requires two POSTs, one for the parent (the interface where the config will be applied) and one for the child (the address and VRF).


CLI Commands

The CLI commands and options listed below are the equivalent to the payload example displayed in the pane on the right.

interface ethernet 1/1
 ip dhcp relay address 128.66.0.0 use-vrf default

For other CLI options, see the Cisco Nexus 9000 Series NX-OS Command Reference: http://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-command-reference-list.html

See the NX-API DME Model Reference for detailed information about classes and attributes described in the payload: https://developer.cisco.com/site/nx-os/docs/nexus-model-reference/

For information about using the payloads, see the Cisco Nexus 9000 Series NX-OS Programmability Guide https://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-programming-reference-guides-list.html

Deleting an IP Address for a DHCP Server

Deleting a Configured IP Address for a DHCP Server
POST http://<IP_Address>/api/mo/sys/dhcp/inst.json
{
  "dhcpInst": {
    "children": [
      {
        "dhcpRelayIf": {
          "attributes": {
            "id": "eth1/1"
          },
          "children": [
            {
              "dhcpRelayAddr": {
                "attributes": {
                  "address": "128.66.0.0",
                  "status": "deleted",
                  "vrf": "default"
}}}]}}]}}
{
    imdata:[]
}
<System>
  <dhcp-items>
    <inst-items>
      <relayif-items>
        <RelayIf-list>
          <id>eth1/1</id>
          <addr-items>
            <RelayAddr-list xc:operation="delete">
              <vrf>default</vrf>
              <address>128.66.0.0</address>
            </RelayAddr-list>
          </addr-items>
        </RelayIf-list>
      </relayif-items>
    </inst-items>
  </dhcp-items>
</System>


CLI Commands

The CLI commands and options listed below are the equivalent to the payload example displayed in the pane on the right.

interface ethernet 1/1
 no ip dhcp relay address 128.66.0.0 use-vrf default

For other CLI options, see the Cisco Nexus 9000 Series NX-OS Command Reference: http://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-command-reference-list.html

See the NX-API DME Model Reference for detailed information about classes and attributes described in the payload: https://developer.cisco.com/site/nx-os/docs/nexus-model-reference/

For information about using the payloads, see the Cisco Nexus 9000 Series NX-OS Programmability Guide https://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-programming-reference-guides-list.html