Skip to content

A CLI to create network namespaces and bridge them together with a single command

Notifications You must be signed in to change notification settings

maykinayki/netns-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Logo

Linux network namespace

NetNS-CLI is a small CLI to create network namespaces and bridge them together with a single command
View tutorial »

Getting Started

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.

Prerequisites

  • Node 14.x
  • yarn
    npm install -g yarn

Installation

  1. Clone the repo
    git clone https://github.com/maykinayki/netns-cli.git
  2. Install packages
    yarn

Usage

  1. Apply the namespace configuration from YAML file
    yarn run apply PATH_TO_CONFIG_FILE.yaml
  2. Delete the namespace configuration from YAML file
    yarn run delete PATH_TO_CONFIG_FILE.yaml

Example

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

Post namespace creation

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.

About

A CLI to create network namespaces and bridge them together with a single command

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published