Skip to content
Advertisement

How to have a separate kernel parameter for a newly created network namespace under Linux?

I am creating a new network namespace called OAM, along wit the veth interfaces to communicate between the new namespace and the default namespace:

JavaScript

Now I check the value of ip_default_ttl parameter from within the default namespace:

JavaScript

It is set to 64. Next I check the same parameter in the newly created OAM namespace:

JavaScript

So, there isn’t a copy of this parameter in the new network namespace.

If I try to test what is the value of TTL in both namespaces by using ping, I can see it’s ttl=64:

Default namespace:

JavaScript

Newly created OAM namespace:

JavaScript

So it seems that even though the ip_default_ttl parameter is not present in the new OAM namespace, the value used is the same (ttl=64). I confirm that by logging in as root into another terminal and changing the ip_default_ttl value from 64 to 32 like this:

JavaScript

Now if I retest the pings to check TTL, I get the same value of ttl=32 in both default and OAM namespace:

JavaScript

So, it seems that the kernel parameter ip_default_ttl defined in the default namespace is used globally across all the network namespaces.

Finally, my question is, what if I want to have different TTL values depending on different namespaces. Is there a way to achieve that ? Is there a way to somehow clone the ip_default_ttl kernel parameter (or other ones which don’t get copied) from default to a newly created network namespace and have a separate value ?

Thanks for your answer in advance.

Advertisement

Answer

Different namespaces and thus containers, etc. operate within a single instance kernel, so parameters like ip_default_ttl are global.

You can however explicitly set hoplimit for routes:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement