Network Namespaces Basics Explained in 15 Minutes

Описание к видео Network Namespaces Basics Explained in 15 Minutes

🆓Join our Slack Community for FREE: https://kode.wiki/JoinOurSlackCommunity

Get introduced to the basics of Network Namespaces in Linux.

Access full course here: https://kodekloud.com/p/certified-kub...

Network Namespaces are used by containerization technologies like Docker to isolate network between containers.

We’ll start with a simple host. As we know already containers are separated from the underlying host using namespaces. So what are namespaces?

When the container is created we create a network namespace for it that way it has no visibility to any network-related information on the host. Within its namespace the container can have its own virtual interfaces, routing and ARP tables. The container has an interface.

To create a new network namespace on a Linux host, run the ip nets add command. In this case we create two network namespaces read and blue. To list the network namespaces run the ip netns command.

To list the interfaces on my host, I run the ip link command. I see that my host has the loopback interface and the eth0 interface. Now, how do we view the same within the network namespace we created? How do we run the same command within the red or blue namespace? Pre-fix the command with the command ip netns exec followed by the namespace name which is red. Now the ip link command will be executed inside the red namespace. Another way to do it is to add the –n option to the original ip link command. Both of these are the same, the second one is simpler though. But remember this only works if you intend to run the ip command inside the namespace. As you can see it only lists the loopback interface. You cannot see the eth0 interface on the host. So with namespaces we have successfully prevented the container from seeing the hosts interface.

#NetworkNamespacesBasics #KodeKloud

Комментарии

Информация по комментариям в разработке