$linuxjunkies
>

network namespace

also: netns

A network namespace is an isolated network environment within a single Linux kernel that allows processes to have separate network interfaces, IP addresses, routing tables, and firewall rules. Multiple namespaces can coexist on one system, each with its own independent network stack.

A network namespace is a kernel feature that virtualizes the network layer, creating isolated network environments. Each namespace has its own set of network interfaces, IP addresses, routing tables, iptables rules, and socket connections, allowing processes within different namespaces to operate as if they were on separate machines.

Network namespaces are fundamental to containerization technologies like Docker and Kubernetes. For example, Docker containers each run in their own network namespace, giving each container its own eth0 interface and IP address while sharing the same physical hardware.

You can manage network namespaces using the ip netns command. To create an isolated namespace named "test": ip netns add test. You can then run commands within it using ip netns exec test bash, which spawns a shell with a completely separate network stack from the host system.

Related terms