This is a systemd service which can be used to create a docker network which will redirect all the traffic to a specific network namespace (netns).
It requires an existing netns which already has an available external connection using a tun link. This can be provided with this openvpn-netns systemd service.
The service will execute the steps explained here.
Run sudo make install
.
You can add as many docker network as you want in different existing network namespaces.
Let's suppose your netns is named vpn0
.
The systemd service will create:
- a new docker network named
vpn0net
- using the ip link
vpn0bridge
. - a pair of veth interfaces
vpn0-int
andvpn0-ext
, inside and outside the netns.
Start the new service:
sudo systemctl start [email protected]
Check the logs:
journalctl -u [email protected]
Enable it at boot:
sudo systemctl enable [email protected]
You can then test your new docker network with --net=vpn0net
:
docker run -it --rm --net=vpn0net --volume /etc/netns/vpn0/resolv.conf:/etc/resolv.conf:ro alpine sh