Linux 101 : Containers networking - Namespaces, virtual bridges and virtual ethernet interface "veth" -
Below are the commands that will be used to create the network namespace, the bridge/virtual switch "br-1", veth pairs "veth_0, veth_1", and wire them together as we can see in the below diagram:
We create the "net_namespace1" namespace using the below command:
Then we create our virtual network cable - veth - which has two ends "veth_0" and "veth_1":
We assign an IP address to the "veth_1" interface:
We activate our virtual switch "bridge_1" using the below command:
We attach the "eth0" interface to our virtual switch "bridge_1":
Then we attach the "veth_0" interface to our virtual switch "bridge_1:
We set the default route for our namespace "net_namespace1" using the below command:
Then we enable ip forwarding on our host to be able to route packets:
Comments