I have an Ubuntu machine with a network namespace (ns1) connected to the host network namespace via veth. I created a MASQUERADE rule in iptables to access the internet and I can ping 8.8.8.8 from the network namespace.
When I do dig google.com
from the host, it works and I see in the main interface:
08:03:02.376478 IP 10.0.10.40.51566 > 10.0.10.2.53: 48449+ [1au] A? google.com. (39)
08:03:02.378335 IP 10.0.10.2.53 > 10.0.10.40.51566: 48449 1/0/1 A 216.58.204.110 (55)
However, when I execute dig in the network namespace: sudo ip netns ns1 dig google.com
, it does not work and this is what I see in the main interface of the host:
08:03:09.033958 IP 10.0.10.40.50888 > 10.0.10.2.53: 32798+ [1au] A? ip-10-0-10-40.eu-west-3.compute.internal. (69)
08:03:09.034152 IP 10.0.10.40.36297 > 10.0.10.2.53: 43961+ [1au] AAAA? ip-10-0-10-40.eu-west-3.compute.internal. (69)
08:03:09.034460 IP 10.0.10.2.53 > 10.0.10.40.50888: 32798 NXDomain 0/1/1 (144)
08:03:09.034460 IP 10.0.10.2.53 > 10.0.10.40.36297: 43961 NXDomain 0/1/1 (144)
08:03:09.034559 IP 10.0.10.40.50888 > 10.0.10.2.53: 32798+ A? ip-10-0-10-40.eu-west-3.compute.internal. (58)
08:03:09.034639 IP 10.0.10.40.36297 > 10.0.10.2.53: 43961+ AAAA? ip-10-0-10-40.eu-west-3.compute.internal. (58)
08:03:09.034837 IP 10.0.10.2.53 > 10.0.10.40.50888: 32798 NXDomain 0/1/0 (133)
08:03:09.034906 IP 10.0.10.2.53 > 10.0.10.40.36297: 43961 NXDomain 0/1/0 (133)
Why the request coming from the network namespace is not trying to resolve hostname google.com
but hostname ip-10-0-10-40.eu-west-3.compute.internal
? The latter is apparently the hostname of my Ubuntu machine
EDIT
If I stop systemd-resolve and add the upstream nameserver, it works. Therefore, it must be an issue with systemd-resolve