I am following the lecture series for the Docker Certified Associate Exam Course. I am currently on chapter “Networking Deep Dive :Namespaces” of the “Docker Engine Networking” section.
As instructed in the lecture, I have created two network namespaces, i.e., red and blue on centos machine as follows:
[[email protected] ~]# ip netns add red
[[email protected] ~]# ip netns add blue
[[email protected] ~]# ip netns
blue
red
I have created the virtual cable ‘veth-red’ and ‘veth-blue’ and then connected them using the following command:
[[email protected] ~]# ip link add veth-red type veth peer name veth-blue
Then I attached the appropriate interface to each namespace as follows:
[[email protected] ~]# ip link set veth-red netns red
[[email protected] ~]# ip link set veth-blue netns blue
I then assigned IP addresses to each of these namespaces as follows:
[[email protected] ~]# ip -n red addr add 192.168.15.1 dev veth-red
[[email protected] ~]# ip -n blue addr add 192.168.15.2 dev veth-blue
I then bring up the interface using the IP link set up command for each device within the respective namespaces.
[[email protected] ~]# ip -n red link set veth-red up
[[email protected] ~]# ip -n blue link set veth-blue up
Then, when I check the interfaces inside each namespace, I get the ‘veth-red’ in ‘red’ namespace and ‘veth-blue’ in blue namespace as follows:
[[email protected] ~]# ip -n red link
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
17: [email protected]: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
link/ether 7e:9d:42:79:2d:2f brd ff:ff:ff:ff:ff:ff link-netnsid 1
[[email protected] ~]# ip -n blue link
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
16: [email protected]: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
link/ether 62:aa:79:55:46:56 brd ff:ff:ff:ff:ff:ff link-netnsid 0
My doubt arises when I try to send a ping from red to blue (IP address: 192.168.15.2) as follows:
[[email protected] ~]# ip netns exec red ping 192.168.15.2
connect: Network is unreachable
Why am I getting ‘Network is unreachable’ when I did everything as instructed in the lecture video?
Please help