Configuring VLANs
The NX-API REST API supports VLAN configuration that is enabled by the following CLI commands:
[no] vlan {vlan-id-create-delete}
switchport access vlan <vlan-id-access> | no switchport access vlan
switchport trunk allowed vlan{ <allow-vlans | add <add-vlans | except <except-vlans> | remove <remove-vlans> | all | none | no switchport trunk allowed vlan
Configuring the Native VLAN ID for a Virtual Ethernet Interface
Configuring the Native VLAN ID for a Virtual Ethernet Interface
POST http://<IP_Address>/api/mo/sys/inftf.json
{
"interfaceEntity": {
"children": [
{
"l1PhysIf": {
"attributes": {
"id": "eth1/1",
"nativeVlan": "vlan-60"
}}}]}}
{
imdata": []
}
<System>
<intf-items>
<phys-items>
<PhysIf-list>
<id>eth1/1</id>
<nativeVlan>vlan-60</nativeVlan>
</PhysIf-list>
</phys-items>
</intf-items>
</System>
Configures the native VLAN ID for the virtual Ethernet interface.
CLI Command
The CLI command below is the equivalent to the payload example displayed in the pane on the right.
interface ethernet 1/1
switchport trunk native vlan 60
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
Enabling Interface VLAN
Enabling Interface VLAN
POST http://<IP_Address>/api/mo/sys/fm.json
{
"fmEntity": {
"children": [
{
"fmInterfaceVlan": {
"attributes": {
"adminSt": "enabled"
}}}]}}
{
imdata": []
}
<System>
<fm-items>
<ifvlan-items>
<adminSt>enabled</adminSt>
</ifvlan-items>
</fm-items>
</System>
This is required before configuring a VLAN interface.
CLI Command
The CLI command below is the equivalent to the payload example displayed in the pane on the right.
feature interface-vlan
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
Creating a VLAN
Creating a VLAN
POST http://<IP_Address>/api/mo/sys/bd.json
{
"bdEntity": {
"children": [
{
"l2BD": {
"attributes": {
"fabEncap": "vlan-50",
"pcTag": "1"
}}]}}}
{
imdata": []
}
<System>
<bd-items>
<bd-items>
<BD-list>
<fabEncap>vlan-50</fabEncap>
<pcTag>1</pcTag>
</BD-list>
</bd-items>
</bd-items>
</System>
Creates a VLAN.
CLI Command
The CLI command below is the equivalent to the payload example displayed in the pane on the right.
vlan 50
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 a VLAN Interface
Configuring a VLAN Interface
POST http://<IP_Address>/api/mo/sys.json
{
"topSystem": {
"children": [
{
"interfaceEntity": {
"children": [
{
"sviIf": {
"attributes": {
"id": "vlan50"
}}}]}}]}}
{
imdata": []
}
<System>
<intf-items>
<svi-items>
<If-list>
<id>vlan50</id>
</If-list>
</svi-items>
</intf-items>
</System>
Configures a VLAN interface.
CLI Command
The CLI command below is the equivalent to the payload example displayed in the pane on the right.
interface vlan 50
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 Switchport Parameters
Configuring Switchport Parameters
POST http://<IP_Address>/api/mo/sys.json
{
"topSystem": {
"children": [
{
"interfaceEntity": {
"children": [
{
"l1PhysIf": {
"attributes": {
"id": "eth1/2",
"layer": "Layer2",
"userCfgdFlags": "admin_layer"
}}}]}}]}}
{
imdata": []
}
<System>
<intf-items>
<phys-items>
<PhysIf-list>
<id>eth1/2</id>
<layer>Layer2</layer>
<userCfgdFlags>admin_layer</userCfgdFlags>
</PhysIf-list>
</phys-items>
</intf-items>
</System>
Configures switchport parameters.
CLI Command
The CLI command below is the equivalent to the payload example displayed in the pane on the right.
interface ethernet 1/2
switchport
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
Setting the Access Mode of an Interface to a VLAN
Setting the Access Mode of an Interface to a VLAN
POST http://<IP_Address>/api/mo/sys.json
{
"topSystem": {
"children": [
{
"interfaceEntity": {
"children": [
{
"l1PhysIf": {
"attributes": {
"accessVlan": "vlan-50",
"id": "eth1/2"
}}}]}}]}}
{
imdata": []
}
<System>
<intf-items>
<phys-items>
<PhysIf-list>
<id>eth1/2</id>
<accessVlan>vlan-50</accessVlan>
</PhysIf-list>
</phys-items>
</intf-items>
</System>
Sets the access mode of the interface to the specified VLAN.
CLI
interface ethernet 1/2
switchport access vlan 50
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 VLANs for a Virtual Ethernet Interface
Configuring VLANs for a Virtual Ethernet Interface
POST http://<IP_Address>/api/mo/sys/intf.json
{
"interfaceEntity": {
"children": [
{
"l1PhysIf": {
"attributes": {
"id": "eth1/2",
"trunkVlans": "70"
}}}]}}
{
imdata:[]
}
<System>
<intf-items>
<phys-items>
<PhysIf-list>
<id>eth1/2</id>
<trunkVlans>70</trunkVlans>
</PhysIf-list>
</phys-items>
</intf-items>
</System>
CLI Command
The CLI command below is the equivalent to the payload example displayed in the pane on the right.
interface ethernet 1/2
switchport trunk allowed vlan 70
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
Adding VLANs to an Interface
Adding VLANs to an Interface
POST http://<IP_Address>/api/mo/sys.json
{
"topSystem": {
"children": [
{
"l1PhysIf": {
"attributes": {
"rn": "phys-[eth1/2]",
"id": "eth3/21",
"descr": "MDT test: trunk port",
"layer": "Layer2",
"mode": "trunk",
"mtu": "9216",
"adminSt": "up",
"trunkLog": "enable",
"trunkVlans": "+2",
"snmpTrapSt": "disable"
}}}}}
{
imdata:[]
}
This example demonstrates how to add VLANs to an interface. In the payload, the rn and trunkVlans properties are required. For the rn property, enter the interface as shown. For the trunkVlans property, enter plus (+) followed by the number of VLANs you want to add. For example: +2.
CLI Command
The CLI command below is the equivalent to the payload example displayed in the pane on the right.
interface ethernet 1/2
switchport trunk allowed vlan add 2
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
Removing VLANs from an Interface
Removing VLANs from an Interface
POST http://<IP_Address>/api/mo/sys.json
{
"topSystem": {
"children": [
{
"l1PhysIf": {
"attributes": {
"rn": "phys-[eth1/2]",
"id": "eth3/21",
"descr": "MDT test: trunk port",
"layer": "Layer2",
"mode": "trunk",
"mtu": "9216",
"adminSt": "up",
"trunkLog": "enable",
"trunkVlans": "-2",
"snmpTrapSt": "disable"
}}}}}
{
imdata:[]
}
This example demonstrates how to remove VLANs from an interface. The rn and trunkVlans properties are required. For the rn property, enter the interface as shown. For the trunkVlans property, enter a minus (-) followed by the number of VLANs you want to remove. For example: -2.
CLI Command
The CLI command below is the equivalent to the payload example displayed in the pane on the right.
interface ethernet 1/2
switchport trunk allowed vlan remove 2
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
Specifying VLANs to Exclude from a List
Specifying VLANs to Exclude from a List
POST http://<IP_Address>/api/mo/sys.json
{
"topSystem": {
"children": [
{
"interfaceEntity": {
"children": [
{
"l1PhysIf": {
"attributes": {
"id": "eth1/2",
"trunkVlans": "1-69,71-4094"
}}}]}}]}}
{
imdata": []
}
<System>
<intf-items>
<phys-items>
<PhysIf-list>
<id>eth1/2</id>
<trunkVlans>1-69,71-4094</trunkVlans>
</PhysIf-list>
</phys-items>
</intf-items>
</System>
Specifies all VLANs to be added to the current list, except the specified VLANs.
CLI Command
The CLI command below is the equivalent to the payload example displayed in the pane on the right.
interface ethernet 1/2
switchport trunk allowed vlan except 70
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 MAC Learning
Disabling MAC Learning on all VLANs on an Interface
Disabling MAC Learning on all VLANs on an Interface
POST http://<mgmt0_IP>/api/mo/sys.json
{
"topSystem": {
"children": [
{
"l2fmEntity": {
"attributes": {
"macLearn": "disable"
}}}]}}
{
"imdata": []
}
<System xmlns="http://cisco.com/ns/yang/cisco-nx-os-device">
<l2fm-items>
<macLearn>disable</macLearn>
</l2fm-items>
</System>
`
This example is only supported on the following platforms: Line cards:
- N9K-9408PC-CFP2
- N9K-X9564PX
- N9K-C9272Q
- N9K-X9464TX
- N9K-X9464TX2
- N9K-X9564TX
- N9K-X9464PX
- N9K-X9536PQ
- N9K-X9636PQ
- N9K-X9432PQ
Switches:
- N3K-C31108TC-V
- N9K-C9332PQ
- N9K-C92160YC-X
- N3K-C3132Q-40GX
- N3K-C3132Q-V
- N9K-C9372PX
- N9K-C9372PX-E
- N3K-C31108PC-V
- N3K-C3172PQ
- N3K-C3172TQ
- N3K-C3164Q
- N9K-C9372TX
- N9K-C9372TX-E
- N9K-C93120TX
- N3K-C31128PQ-10GE
Note: This example was added in Release 7.0(3)I7(3).
CLI Commands
The CLI commands are equivalent to the payload examples displayed in the pane on the right. Click the DME tab in the top-left corner of the right pane to view the JSON payload. Click the YANG tab to view the XML payload.
mac-learn disable
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/media/dme/index.html
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
Enabling MAC Learning on all VLANs on an Interface
Enabling MAC Learning on all VLANs on an Interface
POST http://<mgmt0_IP>/api/mo/sys.json
{
"topSystem": {
"children": [
{
"l2fmEntity": {
"attributes": {
"macLearn": "enable"
}}}]}}
{
"imdata": []
}
<System xmlns="http://cisco.com/ns/yang/cisco-nx-os-device">
<l2fm-items>
<macLearn>enable</macLearn>
</l2fm-items>
</System>
This example is only supported on the following platforms: Line cards:
- N9K-9408PC-CFP2
- N9K-X9564PX
- N9K-C9272Q
- N9K-X9464TX
- N9K-X9464TX2
- N9K-X9564TX
- N9K-X9464PX
- N9K-X9536PQ
- N9K-X9636PQ
- N9K-X9432PQ
Switches:
- N3K-C31108TC-V
- N9K-C9332PQ
- N9K-C92160YC-X
- N3K-C3132Q-40GX
- N3K-C3132Q-V
- N9K-C9372PX
- N9K-C9372PX-E
- N3K-C31108PC-V
- N3K-C3172PQ
- N3K-C3172TQ
- N3K-C3164Q
- N9K-C9372TX
- N9K-C9372TX-E
- N9K-C93120TX
- N3K-C31128PQ-10GE
Note: This example was added in Release 7.0(3)I7(3).
CLI Commands
The CLI commands are equivalent to the payload examples displayed in the pane on the right. Click the DME tab in the top-left corner of the right pane to view the JSON payload. Click the YANG tab to view the XML payload.
no mac-learn disable
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/media/dme/index.html
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