Easy,  on  LinuxContainersNetworking Submissions: 192/290

Docker (and the like) give the containerized application an illusion of having a dedicated network environment. This is achieved by using Linux network namespaces that provide a fully isolated set of network devices, IP protocol stacks, routing tables, firewall rules, etc. for each container.

Linux network namespace

In this challenge, you'll need to create a new network namespace and inspect its network interfaces. How many interfaces a freshly created network namespace has?

First, create a new network namespace called my-net-ns.

Hint 1 💡

There are multiple ways to create a network namespace. For instance, you can use the unshare command or the ip netns command. man unshare and man ip-netns are your friends.

Now, list the network interfaces of the my-net-ns namespace and store the output in the /tmp/my-net-ns-interfaces.txt file.

Hint 2 💡

To list interfaces of a network namespace, you need to execute the ip link ls command in that namespace.

Hint 3 💡

Again, there are multiple ways to execute a command in a network namespace. You can either nsenter it or use the ip netns exec utility. Try man nsenter or man ip-netns for more information.

Level up your server-side game — Join 7,000 engineers who receive insightful learning materials straight to their inbox