NetNS-CLI is a small CLI to create network namespaces and bridge them together with a single command
View tutorial »
To get a local copy up and running follow these simple example steps.
It's been tested in Ubuntu 18.04 and Ubuntu 20.04. For MacOS users it won't work becuase MacOS does not support Linux ip
command.
- Node 14.x
- yarn
npm install -g yarn
- Clone the repo
git clone https://github.com/maykinayki/netns-cli.git
- Install packages
yarn
- Apply the namespace configuration from YAML file
yarn run apply PATH_TO_CONFIG_FILE.yaml
- Delete the namespace configuration from YAML file
yarn run delete PATH_TO_CONFIG_FILE.yaml
I provied an example yaml file in the root of the project netns-config.yaml
.
You can use this file as a template to build your own network namespaces.
We can use the apply
command above to add the namespaces in netns-config.yaml
yarn run apply ./netns-config.yaml
If all went well then you might want to attach your terminal to a namespace. I've provided a bash script in ./scripts/switch-netns.sh
. Simply run the command below:
sudo bash ./scripts/switch-netns.sh
It'll prompt you to enter the name of the namespace you want to attach your terminal. After typing the name simply press enter and here you are, in the namespace.