Use named netns (net namespace) with systemd services!
GPL-3.0 License
This project enables you to:
Dependencies:
/usr/bin/env
For installation, run make install
with root privilege.
You ran run make uninstall
to remove the systemd units, but the configs located in /etc/default
will not be removed.
systemctl start netns-nat@helloworld
chnetns helloworld ip address
Note: Network interface names are derived from the netns name, so do not create netns names longer than 12 characters.
[email protected]
)It creates a new netns. Use this if you want to customize everything by hand. All other types depend on this.
[email protected]
)It creates a new netns with NATed network access (like VMNet8). Use this if you want to get things quickly up and running without any network hassles.
Note:
netns-nat
instance. You need to change the IP addresses if you want 2 or more netns-nat
instances running at the same time.NAT_ACCEPT_TRAFFIC=1
[email protected]
)It creates a new netns with a pseudo wire to the host (like VMNet1). Use this if you want to communicate with the program inside the netns but don't want them to have internet access, or if you want to assign routable IPs to a netns.
[email protected]
)It bridges the new netns to a Linux bridge. You need to set up the bridge first: see wiki if you are not sure what to do.
[email protected]
)Alternative to NSType bridge. A MACVLAN Bridge allows you to create multiple interfaces with different Layer 2 (that is, Ethernet MAC) addresses on top of a single NIC. MACVLAN is a bridge without an explicit bridge device.
For netns-mvbr, ${MACVLAN_BRIDGE}
will be the bridge device (usually your physical NIC device).
Note that any MACVLAN devices in other netns's will be able to communicate each other and the outside world but NOT the bridge device. If you want to enable communication with the root netns, you can add a MACVLAN device in the root netns and use that instead of the MACVLAN bridge device.