Crates.io | netns-utils |
lib.rs | netns-utils |
version | 0.1.0 |
source | src |
created_at | 2023-11-19 13:43:16.879442 |
updated_at | 2023-11-19 13:43:16.879442 |
description | Network Namespace Utils |
homepage | |
repository | https://github.com/guillaumepellegrino/netns |
max_upload_size | |
id | 1041177 |
size | 60,356 |
Create network namespace in one command line !
Usage: netns [OPTIONS] --name <NAME>
Options:
-n, --name <NAME> Name of the network namespace
-i, --ifname <IFNAME> Interface name to enslave in the network namespace
-d, --destroy Destroy the network namespace
-h, --help Print help
-V, --version Print version
guillaume@nix:~$ netns -n test -i enp5s0
Creating network namespace test
Joining network namespace test
guillaume@test:~$ ip link
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp5s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether fc:aa:14:cb:e9:aa brd ff:ff:ff:ff:ff:ff
guillaume@nix:~$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
5: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether de:e8:6d:eb:72:30 brd ff:ff:ff:ff:ff:ff
guillaume@nix:~$ netns -n test
Joining network namespace test
guillaume@test:~$ ip link
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp5s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether fc:aa:14:cb:e9:aa brd ff:ff:ff:ff:ff:ff
guillaume@test:~$ exit
exit
netns reference count: 1
guillaume@nix:~$
guillaume@test:~$ exit
exit
netns reference count: 0
Destroying network namespace test
NETNS Inode: 4026534538
guillaume@nix:~$