When we have more than two namespaces, we use a Linux bridge to connect these namespaces.
To be able to talk to these namespaces the host interface eth0 goes through the Linux bridge. 
Since the Linux bridge is an interface, we can assign an IP address to it so that eth0 can communicate with the namespaces connected to the bridge.


Creating a Linux bridge and assigning an IP address to it:


We enable the bridge interface:


We, then assign an IP address to it:


Now our local host has two interfaces, eth0 : 192.168.1.2 and the bridge interface, bridge_1 : 192.168.0.5.
We can ping the namespaces in the host from the eth0 interface, eth0 is also reachable from within the namespaces.

Network address translation (NAT) :


Since the address of the bridge is internal to the host, all packets going outside of the host can't use it, these packets need to use the eth0 interface, that's where NAT comes in.
NAT replaces all the packets coming from the network 192.168.0.0/24 with the address of the eth0 interface. We enable NAT using:


Accesing the namespaces from outside our local network:

To be able to communicate with the namespaces inside our host, we need to add a default route to our namespaces, so all packets going outside use the bridge_1 interface:


we check the connection to the outside:


Accessing a web server running inside one of our namespace:

To achieve that we would need to enable port forwarding on our host interface, so it can forward traffic coming on the eth0 interface port: 80 to the namespace running the Web server (192.168.0.1, port:80).


Enabling port forwarding on the host:



Brando Sabatini and Ikbal C ©. Powered by Blogger.