A single set of network interfaces and routing table entries are shared across the entire Linux operating system. Network namespaces virtualize these shared resources by providing different and separate instances of network interfaces and routing tables that operate independently of each other.
- Two namespaces are created by default in Linux - default and management. Each maps to VRFs of the same name within NX-OS.
- The default namespace (and VRF) enables access to the front panel ports and tunneling interfaces within Linux.
- The management namespace (and VRF) enables access to the management interface.
- Each new VRF created within NX-OS will map to a corresponding Linux namespace of the same name.
Open NX-OS Linux Network Architecture / Linux Namespace
Note: by default you are in the default
namespace.
List available namespaces:
root@n9k-sw-1# ip netns
management
default
List interfaces available in a namespace:
root@n9k-sw-1# ip link list | grep Eth
88: Eth2-1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 100
89: Eth2-2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 100
90: Eth2-3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 100
91: Eth2-4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 100
Run a process/command/shell within a given namespace:
root@n9k-sw-1#ip netns exec .
root@n9k-sw-1#ip netns exec management bash
Note: VRFs need to be created in NX-OS first to be represented and manipulated as namespaces in Linux.
Create a VRF in NX-OS and move an interface to this VRF:
n9k-sw-1(config)# vrf context red
n9k-sw-1(config-vrf)#
n9k-sw-1(config)# int e2/4
n9k-sw-1(config-if)# vrf member red
Warning: Deleted all Layer-3 config on interface Ethernet2/4
n9k-sw-1(config-if)# ip address 192.168.1.2/24
n9k-sw-1(config-if)#
Check the list of namespaces:
bash-4.2# ip netns list
red
management
default
Observe routing table differences between namespaces
bash-4.2# route
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface
127.1.0.0 * 255.255.0.0 U 0 0 0 veobc
127.1.2.0 * 255.255.255.0 U 0 0 0 veobc
bash-4.2# ip netns exec red route
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 * 255.255.255.0 U 0 0 0 Eth2-4
bash-4.2#
Cisco Open NX-OS is a Linux-based operating system that allows full Linux access to end-users. This includes enabling access and manageability of a Cisco Nexus 9000 and Nexus 3000 Series Switch via standard Linux tools. Further, Open NX-OS includes support for package managers that enable users to build and integrate open source or custom applications natively into NX-OS.