Network Namespaces Basics Explained in 15 Minutes

preview_player
Показать описание

Get introduced to the basics of Network Namespaces in Linux.

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
Рекомендации по теме
Комментарии
Автор

This took me 1 month to learn by self and you visualized in 15 minutes. Believe me.. you covered everything. Good Work

manishfoodtechs
Автор

Great Work KodeKloud!
If the pings do not work - make sure you add ip addresses as 192.168.15.1/24 and 192.168.15.2/24 and for the bridge example make sure you also bring up the peer devices (veth-red-br and veth-blue-br) using following commands - sudo ip link set veth-red-br up and sudo ip link set veth-blue-br up before testing the pings.

nikhilpurwant
Автор

Wow. Entire Namespace condensed to 15 min and explained well as well. This should be the go-to tutorial for networking with Namespaces

agytjax
Автор

Awesome video, Love this guy helped me pass my kube certs. BTW on amazon linux 2, I had to use 192.168.15.1/24 and 192.168.15.2/24 for red and blue namespaced network, otherwise could not ping.

zahurulhaque
Автор

Hi thanks for the video ! When following along, I noticed that there are 2 important things not mentioned in this video in order for this to work:
1. We need to set up the interfaces that are mastered by the bridge network.
2. We need to enable ip forwarding for the machine, i.e.: sysctl -w net.ipv4.ip_forward=1

yoavklein
Автор

I rarely comment on any video.
But this amazing video forces me to comment.
Great explanation. Thanks!

abobakrabdellah
Автор

This is the best explanation ever! Thank you so much.

shrutidalvi
Автор

This is by FAR the best description of network namespaces I've ever seen! Thank you for putting this together!

saiyjin
Автор

Teaching is a talent and you are amazingly talented. Best explanation ever

zaherer
Автор

God level teaching....Im literally speechless.Was struggling with openstack ping issues.this saved my life.

christymathew
Автор

WOW, in 15 mints you explained one of the most complicated subjects I didn't understand, simply by telling us the "why"
I hope I can make 1000 like, thank you

mrashad_com
Автор

This is just awesome. Docker kept rolling in my mind for the entire video and helped me understand the implementation.
Well, the first time, it went a little over my head because of less networking understanding. Watching it for many times to grasp everything. Thank you again, you're the best teacher!

iammrchetan
Автор

Great tutorial. The title can also be how to create a virtual Linux router. It s basically what a router do, besides the iptables rules then it completed.

upsangelhk
Автор

You are the Best Explainer Man... You truly make Difficult Topics understandable very easily...❤❤❤

AnantaAkash.Podder
Автор

Awesome explanation. Simply superb video

pankajchaurasia
Автор

Please do more in depth courses like these (cgroups, overlay networks). I'm currently interested in what are pods concretely. From what I understood until now, it's just a bunch of containers (i.e a bunch of uts+pid+network+ipc) that belongs to the same network namespace.

imanebt
Автор

excellent explanation, I. would watch this video 100 times, thanks

ar
Автор

Very clear technical explanation, you can understand how networking is working within container, and between them! Really excellent, please continue...

spoown
Автор

Awesome video with so much details compressed yet very much clear and precise explanation. Analogy was simply superb which I could not find in any videos and articles till now. Thank you :)

sandeepr
Автор

Dammn Man, you are the Guy. thank you for this incredible lesson, I spent 1 week trying to understand these concepts, and now with your video, I understood everything in just 15 min.

amilcarchissola
welcome to shbcf.ru