I am running a docker on a host and I would like to connect a specific interface inside the docker (TUN interface) to one the host's external interfaces.
When running ifconfig
inside the docker, I see 3 interfaces: eth0
, lo
and my_tun
(tun interface).
On the host, I see lo
, docker0
and enp7s0
(external network).
The result I seek for, is that packets that are sent on the my_tun
interface will be sent to the enp7s0
.
If the TUN interface was not inside a docker, I would do something like:
sysctl -w net.ipv4.ip_forward=1
sudo iptables -t nat -A POSTROUTING -o enp7s0 -j MASQUERADE
So my question is how to do it with a TUN interface that belongs to a docker container (preferably on Ubuntu).
Thanks in advance!