Skip to content

Commit

Permalink
Added Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
grapheo12 committed Feb 4, 2021
1 parent 8ef3b36 commit ebce78a
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 0 deletions.
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (C) 2021 Shubham Mishra

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
86 changes: 86 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Net-compose

Brother of docker-compose. Handles only Network Namespaces

## Capabilities

- [x] Creating and removing network namespaces
- [x] Support for Veth pairs
- [ ] Support for Bridges and other devices
- [x] Adding routing entries to devices, with nexthop
- [ ] Support for default gateway
- [x] Shell using a particular namespace


## Installing

This project works in Linux.
Make sure you have the following dependencies installed:

- golang
- iproute2
- make


In the project folder, run:

```bash
make && sudo make install
```

The executable `net-compose` will be installed in `/usr/bin`.


## Usage

See sample configs in the `test` folder

### Establish a virtual network

Create a config file following the format in the given examples.
(Let's say its name is `compose.yaml`)

To see what commands will be run to create the namespace, run:

```bash
net-compose compose.yaml dry-run
```

Currently the `up` command is defunct. :sweat-smile:

To really create the network, for now, you can do:

```bash
net-compose compose.yaml dry-run | sudo sh -
```


### Deleting the network

For now, anything created on the default namespace stays.
The cleanup operation deletes all the namespace.

To see the commands that will be used to delete the network, run:

```bash
net-compose compose.yaml down
```

To execute these commands, run:

```bash
net-compose compose.yaml down | sudo sh -
```


### Shell in a namespace

To open a shell where you can execute commands from a particular namespace, run:

```bash
sudo net-compose compose.yaml shell <name-of-the-namespace>
```

The namespace should be present in `compose.yaml` and the network must be established beforehand.

To exit from the shell, enter the `exit` command or press `Ctrl+C`.
1 change: 1 addition & 0 deletions cmd/net-compose/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

func usage() {
fmt.Println("Usage: net-compose compose.yaml (up|down|dry-run|shell namespace)")
fmt.Println("You might need to run with root privileges")
}

func main() {
Expand Down

0 comments on commit ebce78a

Please sign in to comment.