Use it to troubleshoot container networking or to test network setups in isolation.
Network Namespaces
A network namespace is an isolated copy of the network stack — its own interfaces, addresses, routes and firewall rules. Containers each get one; ip netns manages named ones.
1. ip netns list — named namespaces.
2. Container: nsenter -t <pid> -n ip -br addr.
3. Routes inside: nsenter -t <pid> -n ip route.
4. veth peer on the host side up and in the bridge?
5. Test from inside: nsenter -t <pid> -n ping <dest>.
namespace created → veth/interface moved in → address and route set → connected via bridge or routing → traffic flows
For Linux Networking → Network Namespaces, continue with the first unproven Topic check: Identify process network namespace and enumerate interfaces by ifindex within it. If that boundary is healthy, advance to the adjacent check: Map veth peer ifindexes and bridge/master connections between namespaces. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
process → network namespace → netdevice/veth identity → address/route/neighbor/firewall state → bridge/upstream attachment → remote path → socket → workload
Healthy evidence: the application process, interfaces and routing state are in the intended namespace, veth/bridge links map correctly, namespace-local policy is valid and the exact application flow succeeds.
Step 2 Preserve namespace context through the original test Verify boundary
Run verification from the same namespace and process identity that originally failed. Confirm the selected route and source address, then capture or count packets on the namespace interface and its host-side peer. Verify the host or bridge forwards the packet and that return traffic is delivered back to the namespace. Finally repeat the original application operation rather than substituting only ping, because DNS, TCP ports, source binding and policy can differ. If the namespace is created dynamically by a container runtime or service manager, also verify that recreation produces the same interfaces, routes and policy; a manual repair inside a transient namespace may disappear on restart.
Step 3 Verification and output interpretation Verify boundary
Existing fast checks for this Topic. - Identify process network namespace and enumerate interfaces by ifindex within it.
- Map veth peer ifindexes and bridge/master connections between namespaces.
- Inspect address, route, neighbor, firewall and listening sockets inside the target namespace.
- Test the original flow from the same namespace/source context as the application.
Verification chain. process → network namespace → netdevice/veth identity → address/route/neighbor/firewall state → bridge/upstream attachment → remote path → socket → workload
Step 4 Specialized verification Verify boundary
Identify the process and its network namespace inode, then execute link/address/route/socket inspection in that namespace. Correlate veth peer ifindexes and host bridge/tap membership instead of relying only on interface names. Trace a test flow across namespace route, neighbor, firewall and host forwarding/NAT boundaries. If a namespace name is missing, inspect process namespace references before assuming the network stack disappeared. Show both directions for flows that require return traffic.
Step 5 Commands Verify boundary
ip netns list
ip netns exec ns1 ip addr
ip -n ns1 route
Step 6 Walk from process to peer instead of testing only the host Narrow the fault
If a namespaced application cannot connect, begin inside the exact namespace: verify interface state, address, route selection, neighbor resolution and the local listening or client socket. Then inspect the veth peer and any bridge, VLAN or host route that carries the traffic onward. If packets leave the namespace but disappear on the host, evaluate nftables/iptables, forwarding sysctls, NAT and reverse-path behavior. If the host can reach the destination while the namespace cannot, that is evidence of different routing or policy context, not evidence that the remote service is healthy. Captures on both veth endpoints are especially useful because they isolate whether loss occurs before or after the namespace boundary.
Step 7 Failure modes and next checks Narrow the fault
Suspicious evidence: diagnostics are run in the wrong namespace, veth peers are misidentified, a process listens only in another namespace or host connectivity masks isolated route/firewall failures.
Step 8 Special cases and limits Narrow the fault
Host network success does not show container/namespace success, and namespace-local localhost never means the host’s loopback. Identical interface names can exist in different namespaces. Deleting a named netns handle does not necessarily terminate processes holding that namespace. Firewall rules and sysctls can be namespace-specific. Keep process namespace identity, virtual link topology, host forwarding and external reachability distinct.
Step 9 Common mistakes Narrow the fault
- Forgetting that namespaces have their own routing and firewall.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
Commands run inside a namespace see only its interfaces: use ip netns exec <ns> <cmd> or nsenter -t <pid> -n <cmd> for a container's PID. veth pairs connect a namespace to a bridge or the host.
nsenter -t <pid> -n ip -br addr— network view of a process/containerip -br addr— interfaces and addressesip route— routing table and default routeip neigh— ARP/neighbour cacheip route get <dest>— route, interface and source chosen for a destinationnmcli device status / networkctl— which tool manages each interface
ReferenceWhat it is1 section · depth on demand
Core model
Pin the namespace of both the process and interface before interpreting any network output. Map veth peers, bridges and namespace moves, then inspect routes/neighbors/firewall/listeners inside the relevant namespace. Host namespace success does not show a container or service namespace has the same path.
ReferenceHow it works1 section · depth on demand
Per-namespace network stacks and veth boundaries
A Linux network namespace has its own interfaces, addresses, routes, policy rules, neighbor tables, sockets and many network sysctls. The loopback interface is namespace-local, so 127.0.0.1 inside a container or namespace does not refer to the host loopback. veth pairs form a common boundary: one endpoint can live in the namespace while the peer stays in the host namespace or connects to a bridge. Packets crossing that pair then encounter host routing, bridging, firewall and NAT according to the actual topology. A process is bound to a network namespace, not merely a filesystem or PID namespace, so always establish the process-to-netns mapping before interpreting ip addr, ip route or socket output.
ReferenceImportant terms & boundaries6 sections · depth on demand
What this shows and what it does not
Namespace-local connectivity shows only that isolated network stack; host/default namespace evidence cannot substitute for the application namespace path.
In depth
Network namespaces
A network namespace is a separate copy of the network stack, with its own interfaces, addresses, routes, firewall rules and sockets. Containers rely on them, and so do VRF-like separation on Linux and lab setups. ip netns manages named namespaces, and the ip-netns(8) manual page explains the conventions:
- A named namespace is an object at
/var/run/netns/NAME, kept alive by that bind mount or by any open file descriptor. ip netns execruns a command inside the namespace.- For programs that aren't namespace-aware,
execoverlays/etc/netns/NAME/files, such asresolv.conf, on top of/etc. - Interfaces are moved into a namespace with
ip link set dev <if> netns <name>.
Subcommands (manual)
| Command | Purpose |
|---|---|
ip netns add <name> / delete <name> | Create or remove a named namespace |
ip netns list | Named namespaces |
ip netns exec <name> <cmd> | Run a command inside |
ip netns identify <pid> | Which namespace a process is in |
ip netns pids <name> | Processes in a namespace |
ip netns attach <name> <pid> | Give a name to a process's existing namespace |
ip netns monitor | Watch namespaces being added and removed |
A two-namespace lab with a veth pair
host$ sudo ip netns add red
host$ sudo ip netns add blue
host$ sudo ip link add veth-red type veth peer name veth-blue
host$ sudo ip link set veth-red netns red
host$ sudo ip link set veth-blue netns blue
host$ sudo ip -n red address add 10.99.1.1/30 dev veth-red
host$ sudo ip -n blue address add 10.99.1.2/30 dev veth-blue
host$ sudo ip -n red link set veth-red up
host$ sudo ip -n blue link set veth-blue up
host$ sudo ip netns exec red ping -c 2 10.99.1.2
host$ sudo mkdir -p /etc/netns/red && echo "nameserver 10.20.0.53" | sudo tee /etc/netns/red/resolv.conf
host$ sudo ip netns exec red cat /etc/resolv.conf
Finding a container's namespace
Containers usually don't create a name under /var/run/netns, so ip netns list doesn't show them. Take the container's process ID and run nsenter -t <pid> -n ip address, or ip netns attach <name> <pid>, to inspect its network stack with the normal tools.
Deleting with processes inside
The manual warns about deleting a namespace while processes still run in it. A physical interface moved into it then only returns to the default namespace once those processes exit. Stop them first with ip netns pids <name> | xargs kill.
Documented example, not captured output.
How it works at runtime
Network Namespaces is part of Linux Networking → Network Namespaces. Linux network namespaces isolate network devices, addresses, routes, neighbor tables, firewall state and sockets; the same interface name or IP can exist independently in different namespaces, making namespace context a first-class diagnostic boundary.
Topic-specific state model. Linux network namespaces isolate network devices, addresses, routes, neighbor tables, firewall state and sockets; the same interface name or IP can exist independently in different namespaces, making namespace context a first-class diagnostic boundary.
Interpretation rule. - Same interface name ≠ same netdevice across namespaces.
- Host route/address state ≠ container/service namespace state.
- veth peer UP ≠ bridge/upstream path or namespace route is valid.
- Process exists ≠ it is listening in the namespace where clients expect it.
Specialized mechanics
A Linux network namespace owns an independent network stack: interfaces, routes, neighbor tables, sockets, firewall state and many network sysctls are scoped to it. veth pairs commonly connect namespaces to another namespace or host bridge, while physical interfaces can be moved between namespaces. Processes observe the network namespace they are attached to, so “localhost”, interface names and routing tables are context-dependent rather than host-global facts. Namespace identity is tied to the namespace object rather than its ip-netns display name, so renamed or bind-mounted namespace handles can still refer to the same stack.
Quick reference
Network namespaces give processes an isolated network stack (interfaces, routes, firewall) — the basis of containers.
ip netns add test
ip link add veth0 type veth peer name veth1
ip link set veth1 netns test
ip addr add 10.99.0.1/24 dev veth0; ip link set veth0 up
ip netns exec test ip addr add 10.99.0.2/24 dev veth1
ip netns exec test ip link set veth1 up; ip netns exec test ip link set lo up
ip netns exec test ping -c1 10.99.0.1
nsenter -t <container-pid> -n ip addr # enter a container's netns
lsns -t net
Troubleshoot container networking by entering the namespace and using normal tools (ss, ip route, tcpdump).
Limits and how it fails
Primary failure point. Namespace-local connectivity shows only that isolated network stack; host/default namespace evidence cannot substitute for the application namespace path.
ReferenceConfiguration & state2 sections · depth on demand
Configuration, persistence and lifecycle
Distribution/platform context. Network Namespaces owns Linux network-stack isolation and namespace context. Containers may orchestrate namespaces but container lifecycle stays in Containers; bridge/VLAN/bond Topics own their device semantics.
Specialized lifecycle
Namespace topology should define explicit attachment points, addresses, routes, forwarding and firewall/NAT policy. Persistent ownership often belongs to a container runtime, systemd-networkd/NetworkManager integration or orchestration layer rather than ad hoc ip netns commands. Moving an interface changes which namespace owns it. When using named netns handles, remember that process namespaces can outlive a deleted name while references remain. Document where policy is applied: inside the namespace, on the host bridge, or at an upstream interface.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Linux Networking → Network Namespaces. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.kernel.org/networking/index.html · confidence 94%Authoritative Linux project/vendor documentation reviewed for bounded reference claims: isolated network stacks, namespace identity and veth/interface ownership. Documentation-based technical verification only; not lab or production-runtime proof. The schema vendor_doc method is used for authoritative project/vendor documentation; deployment applicability remains separate evidence.
Basis: https://man7.org/linux/man-pages/man7/network_namespaces.7.html · confidence 93%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Network Namespaces operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for Network Namespaces.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | Linux network namespaces isolate network devices, addresses, routes, neighbor tables, firewall state and sockets; the same interface name or IP can exist independently in different namespaces, making namespace context a first-class diagnostic boundary. | Establish exactly what this Topic owns before crossing into another subsystem. |
| Fast verification | Pin host + namespace + exact flow → identify configuration owner/renderer → identify ifindex/interface + topology → inspect link/carrier → inspect addresses → inspect neighbor resolution → reproduce route/rule lookup → verify VLAN/bond/bridge/MTU as relevant → inspect packets/socket → verify return path → repeat original workload. | Use the shortest evidence path first; a fast check is a boundary test, not blanket proof. |
| Verification chain | process → network namespace → netdevice/veth identity → address/route/neighbor/firewall state → bridge/upstream attachment → remote path → socket → workload | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | Namespace-local connectivity proves only that isolated network stack; host/default namespace evidence cannot substitute for the application namespace path. | Stop broad troubleshooting at the first boundary that is not supported by evidence. |
| Positive evidence | Correlated Linux networking evidence can establish this proof path: process → network namespace → netdevice/veth identity → address/route/neighbor/firewall state → bridge/upstream attachment → remote path → socket → workload | Use this observation only for the specific claim it actually supports. |
| Evidence limit | It does not independently prove behavior outside the captured namespace, interface, local kernel, L2/path or workload scope. Namespace-local connectivity proves only that isolated network stack; host/default namespace evidence cannot substitute for the application namespace path. | Do not promote a local success signal into end-to-end or adjacent-dependency proof. |
| Next troubleshooting check | Continue from the first unproven boundary: confirm namespace and configuration owner, inspect ifindex/link/address/neighbor/route state for the exact flow, verify L2/MTU construction and packet movement, then test the listening service and return path before making additional changes. | Continue to the next unresolved boundary while preserving the original test condition. |
Network Namespaces · operational reference
Compact Linux state, persistence, verification and boundary reference for fast lookup.
| Reference boundary | Network Namespaces |
|---|---|
| Topic path | Linux Networking → Network Namespaces |
| Runtime state | Linux network namespaces isolate network devices, addresses, routes, neighbor tables, firewall state and sockets; the same interface name or IP can exist independently in different namespaces, making namespace context a first-class diagnostic boundary. |
| Fast checks | - Identify process network namespace and enumerate interfaces by ifindex within it. - Map veth peer ifindexes and bridge/master connections between namespaces. - Inspect address, route, neighbor, firewall and listening sockets inside the target namespace. - Test the original flow from the same namespace/source context as the application. |
| Verification chain | process → network namespace → netdevice/veth identity → address/route/neighbor/firewall state → bridge/upstream attachment → remote path → socket → workload Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. |
| Failure boundary | Namespace-local connectivity proves only that isolated network stack; host/default namespace evidence cannot substitute for the application namespace path. Boundary chain: process/socket namespace → source/rule/FIB → neighbor → netfilter/eBPF/qdisc → virtual/physical device → peer → return → application. |
| Persistence rule | Prove which configuration source owns the state, then prove that the running consumer loaded or generated the intended state. |
Network Namespaces · specialized operational reference
Topic-specific Linux mechanics, lifecycle, proof path and failure-boundary lookup.
| Operational boundary | Topic-specific reference |
|---|---|
| Scope | interfaces/routes/neighbors/sockets/firewall per netns |
| Identity | Process netns inode + named handle if present |
| Linking | veth peer / bridge / physical move |
| Proof | Trace request + return path across namespace boundaries |