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_namespace1namespace using the below command:


Then we create our virtual network cable - veth - which has two ends "veth_0" and "veth_1":


We "attach" the "veth_1" end of the virtual cable to the "net_namespace1" namespace:


We assign an IP address to the "veth_1" interface:


T
hen we enable the "veth_1" interface inside the "net_namespace1namespace :


We create our virtual switch that will connect the "net_namespace1" namespace to our host's interface "eth0":


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_namespace1using the below command:


Then we enable ip forwarding on our host to be able to route packets:

Comments

Leave as a comment:

Archive