My laptop has an IPsec VPN tunnel set up to access a remote site (with my side being the VPN client).
As an experiment, I started up a simple docker container on my laptop using docker run --rm -it alpine:3.7 /bin/sh
and from within the container tried to ping one of the remote machines on the other side of the tunnel.
I expected the ping to not work, but I was surprised that it actually did.
I expected that in order to be able to access one of the remote machines from within a docker container, I'd have to first set up the VPN connection from within the container.
If not a full-fledged VPN connection from within the container, I thought that I would at least need to set up some iptables
rules on the host machine. (My laptop's private IP address is 192.168.10.1
, that of the remote server is 10.2.5.100
and that of my docker container is 172.17.0.2
.) But even this wasn't needed...
So my question is how is it that communicating with the remote machines through the tunnel just works without any additional setup?
p.s. in case it matters, my laptop is running Arch Linux and I'm using strongswan to set up the IPsec connection.