{"id":952,"date":"2015-11-09T22:20:51","date_gmt":"2015-11-09T22:20:51","guid":{"rendered":"https:\/\/fir3netwp.gmsrrpobkbd.com\/2015\/11\/09\/linux-network-namespaces\/"},"modified":"2021-07-31T16:15:01","modified_gmt":"2021-07-31T16:15:01","slug":"linux-network-namespaces","status":"publish","type":"post","link":"https:\/\/www.fir3net.com\/UNIX\/Linux\/linux-network-namespaces.html","title":{"rendered":"Linux Network Namespaces"},"content":{"rendered":"
The Linux Network Namespace (netns) is a feature within the 2.6.27+ Linux kernel. Normally a Linux process will run within a network namespace. By default this is inherited from its parent process. Network namespaces allow for the process to run within a different network namespace. This allows \u00a0for virtual instances of the Linux network stack each with its own routes, firewall rules and network devices.<\/p>\n
A great example of network namespaces in use can be seen within OpenStack Neutron.\u00a0 Neutron, the networking component of OpenStack uses network namespaces\u00a0 to provide network isolation between tenants.<\/p>\n
First of all to list the current namespaces the ip netns list<\/span> command is used.<\/p>\n To execute a command within the namespace the command ip netns <namespace_id> <command><\/span>.<\/p>\n Some typical Linux network commands that can be used are,<\/p>\n This example touches only on the listing and exec of the network namespaces. There are other commands available such as creating and removing namespaces. Further details on these commands can be found here<\/a>.<\/p>\n The Linux Network Namespace (netns) is a feature within the 2.6.27+ Linux kernel. Normally a Linux process will run within a network namespace. By default this is inherited from its parent process. Network namespaces allow for the process to run within a different network namespace. This allows \u00a0for virtual instances of the Linux network stack … Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[52],"tags":[],"yoast_head":"\nroot@controller01:~# ip netns list<\/strong>\r\nqrouter-e945b6b1-54be-49ef-95ed-5d524d2f3616\r\nqdhcp-dae14f7d-c7f9-4dbc-9635-603f0fbc3f09<\/pre>\n
EXEC Namespace<\/h2>\n
root@controller01:~# ip netns exec qrouter-e945b6b1-54be-49ef-95ed-5d524d2f3616 ifconfig<\/strong>\r\nlo Link encap:Local Loopback\r\n inet addr:127.0.0.1 Mask:255.0.0.0\r\n inet6 addr: ::1\/128 Scope:Host\r\n UP LOOPBACK RUNNING MTU:65536 Metric:1\r\n RX packets:0 errors:0 dropped:0 overruns:0 frame:0\r\n TX packets:0 errors:0 dropped:0 overruns:0 carrier:0\r\n collisions:0 txqueuelen:0\r\n RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)\r\n\r\nqg-e5b9712e-b0 Link encap:Ethernet HWaddr fa:16:3e:a7:8a:df\r\n inet addr:172.16.100.30 Bcast:172.16.100.255 Mask:255.255.255.0\r\n inet6 addr: fe80::f816:3eff:fea7:8adf\/64 Scope:Link\r\n UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1\r\n RX packets:384847 errors:0 dropped:0 overruns:0 frame:0\r\n TX packets:16 errors:0 dropped:0 overruns:0 carrier:0\r\n collisions:0 txqueuelen:1000\r\n RX bytes:62660634 (62.6 MB) TX bytes:1200 (1.2 KB)\r\n\r\nqr-76de6d23-a8 Link encap:Ethernet HWaddr fa:16:3e:32:78:9d\r\n inet addr:10.1.1.1 Bcast:10.1.1.255 Mask:255.255.255.0\r\n inet6 addr: fe80::f816:3eff:fe32:789d\/64 Scope:Link\r\n UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1\r\n RX packets:266390 errors:0 dropped:0 overruns:0 frame:0\r\n TX packets:10 errors:0 dropped:0 overruns:0 carrier:0\r\n collisions:0 txqueuelen:1000\r\n RX bytes:51963537 (51.9 MB) TX bytes:864 (864.0 B)<\/pre>\n
\n
Additional Commands<\/h2>\n
Usage: ip netns list\r\n ip netns add NAME\r\n ip netns delete NAME\r\n ip netns identify PID\r\n ip netns pids NAME\r\n ip netns exec NAME cmd ...\r\n ip netns monitor<\/pre>\n
Additional Links<\/h2>\n
\n