Search code examples
dockerdocker-network

From docker container cant access 192.168.2.* network which is under VPN


The container connects to external servers and executes code there.

These external servers are behind a VPN. From the local host I can connect to them, either by name or by direct IP.

But for some reason, to the servers in the subnet 192.168.2.* I can not connect from the container. But I can connect to subnets 192.168.123.* (also under VPN).

DNS servers are given to me through the VPN 192.168.2.1 and 192.168.123.1. I tried to assign the same DNS to the container through the key --dns, nothing changes.

Pinging by domain name server1.company.com extracts correct address 192.168.2.200 and thats all.

Does anyone have any ideas?


Solution

  • Answering my own question.

    There's no magic here, after all.

    with the command scutil --dns I found out which nameservers added by VPN and just added them to docker run ... command like:

    --dns=192.168.2.1 --dns=192.168.123.1 --publish-all
    

    and now it works fine.

    PS: But I still dont have any idea how it worked before (.