Skip to content

Create and Delete Netns

James Swineson edited this page Nov 2, 2017 · 1 revision

Create netns

Assume you want to create a netns named foo. (Note: do not use -, space or other strange characters in netns name!)

Just a plain netns without external networking

This is just a netns; there is only an lo interface inside it. No external network access.

systemctl start netns@foo

Pre-configured External Access

In this case, a veth pair will be set up automatically to tunnel packets between netns and host. Note that netns@foo.service will be started too.

Bridged to host network

systemctl start netns-bridge@foo

(For the default config, it will bridge to br0. You should create the bridge first. See wiki/bridging)

NATed

systemctl start netns-nat@foo

Persistent netns

Just systemctl enable it.

Stop and Remove netns

Use this even if you started using preconfigured method:

systemctl stop netns@foo