Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information. Upgrade to cni spec v0.4.0. Apr 29, 2019
cnitool.go Validate correct number of args in cnitool Nov 29, 2018


cnitool is a simple program that executes a CNI configuration. It will add or remove an interface in an already-created network namespace.

Example invocation

First, install cnitool:

go install

Then, check out and build the plugins. All commands should be run from this directory.

git clone
cd plugins
# or

Create a network configuration

echo '{"cniVersion":"0.4.0","name":"myptp","type":"ptp","ipMasq":true,"ipam":{"type":"host-local","subnet":"","routes":[{"dst":""}]}}' | sudo tee /etc/cni/net.d/10-myptp.conf

Create a network namespace. This will be called testing:

sudo ip netns add testing

Add the container to the network:

sudo CNI_PATH=./bin cnitool add myptp /var/run/netns/testing

Check whether the container's networking is as expected (ONLY for spec v0.4.0+):

sudo CNI_PATH=./bin cnitool check myptp /var/run/netns/testing

Test that it works:

sudo ip -n testing addr
sudo ip netns exec testing ping -c 1

And clean up:

sudo CNI_PATH=./bin cnitool del myptp /var/run/netns/testing
sudo ip netns del testing
You can’t perform that action at this time.