How to create permanent linux network namespace

iproute2linux-networkingnetwork-namespace

I know that ip netns add xxx command can be used to create a linux network namespace, but it is not permanent, meaning after server reboot the created namespace will be gone.

Then how can I create a permanent one which can survive server reboot?

Best Answer

Network namespaces are not persistent across system restarts. You will need to create a script that is run at startup and arrange to have it run.

How you cause it to run depends on your needs, you may be able to cal it from /etc/rc.local or you may be able to hook it into some other script. You may find that you need to hook it into the init system (init scripts/systemd etc) for your (unnamed) OS/Distro.