Can only access other containers via private IP, not DNS service/container name #114
Unanswered
brstreetlaw
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using:
network_mode: service:vpn
And everything almost works. The main problem is that my nordlynx container, and every other container networked behind it, can only ping the non-VPN containers using their local/private IP addresses, but not using their DNS names.
Here's how the stack / docker-compose yaml begins and ends for nordlynx:
I would like to not have to hard-code references to the IP addresses of my containers into the configuration of other containers, because Docker dynamically assigns these IP addresses and can even change subnets if I ever decide to re-create the user-defined network.
Having my VPN-networked containers communicate with my non-VPN containers via the reverse proxy isn't always viable, as the reverse proxy forces an SSL connection through an HTTPS address, while internal communication between containers (e.g. http://lidarr:8686/) can be safely non-encrypted. (My other containers have no problem reaching flaresolverr via http://vpn:8191 this way.)
Am I asking too much here? I feel like I'm very close to getting the right nordlynx environment variables to make these other containers locally accessible from the nordlynx container via their service and container names.
Seeing as this seems DNS-related, I used the command
cat /etc/resolv.conf
in each container's CLI. All the non-VPN containers havemeanwhile, nordlynx and its
network-mode service:vpn
associated containers all showAs a possible solution, if I set the POST_UP environment variable to something like
echo 'nameserver 127.0.0.11' >> /etc/resolv.conf'
will I be creating a DNS leak? How do I ensure that nordlynx only uses 127.0.0.11 to resolve local hostnames and not public URLs?(Note: I tried exactly this but then from a CLI within nordlynx container, the 127.0.0.11 line is still missing from /etc/resolv.conf.)
from logs:
EDIT 2: so instead I used the environment variable
DNS=103.86.96.100,103.86.99.100,127.0.0.11
which appears to resolve the problem above - the VPN containers can ping external URLs and also internal hostnames. But (a) how do I make sure only the internal hostnames are resolved through 127.0.0.11 and not external URLs, and (b) what's the likelihood that either NordVPN changes their two DNS IPs or Docker changes their internal DNS IP?EDIT 3: when I use the DNS environment variable as above and then do
nslookup google.ca
from a CLI within the nordlynx container, it pretty much confirms that only 127.0.0.11 is being used to resolve that domain name - even though the subsequent pings to google.ca only go out over the wg0 interface. In this scenario,/etc/resolv.conf
only containsnameserver 127.0.0.11
.EDIT 4: at least when NordVPN is properly connected, the closest I have come is to go into the nordlynx container CLI and run
echo 'nameserver 127.0.0.11' >> /etc/resolv.conf
so that there is now a 3rd DNS server.nslookup
shows external URLs being resolved using the NordVPN DNS servers (103.86.96.100) while local container or server hostnames are resolved by 127.0.0.11. As noted above, thePOST_UP
environment variable can't seem to run this same command properly - and the solution seems to allow DNS leaks.Beta Was this translation helpful? Give feedback.
All reactions