You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inside a network namespace we create, I see DNS resolve error:
user@intel:~/go/src/github.com/Lylelee/jail-program$ sudo ip netns exec jailns bash
root@intel:~/go/src/github.com/Lylelee/jail-program# ping www.baidu.com
ping: www.baidu.com: Temporary failure in name resolution
Because ping tries to talk to DNS server, which locate default at 127.0.0.53, for DNS resolving. Unfortunately, there is no one listen there, since the network namespace is isolate.
According to man ip-netnslink, placing a independent file resolv.conf, at which explicit point to a nameserver, to /etc/netns/{nsName}/resolv.conf solve the problems
But, when I write my own code and execute a command inside the same network namespace seeing problems again. I can't tell the exact cause.
/bin/bash -c ping -c 3 www.baidu.com
exit status 2
ping: www.baidu.com: Temporary failure in name resolution
ip netns could have read /etc/netns/{nsName}/resolv.conf and bind mount it into namespace /etc/resolv.conf. but I can't find related code on ip route2 git repo
Finally, the compromise is replacing host /etc/resolv.conf default setting with my custom nameserver.
nameserver 114.114.114.114
OS&kernel:
VERSION="18.04.2 LTS (Bionic Beaver)"
Linux 4.15.0-106-generic #107-Ubuntu SMP Thu Jun 4 11:27:52 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Be careful:
/etc/resolv.conf is controlled by systemd-resolved.service. And could be overwritten anytime.
I can verified it by fire:
sudo systemctl restart systemd-resolved.service
The text was updated successfully, but these errors were encountered:
It works, but /etc/netns/jailns/resolv.conf propagate to host /etc/resolv.conf even the program exits. we have to manually umount /etc/resolv.conf after that.
I think chroot my help.
Inside a network namespace we create, I see DNS resolve error:
Because ping tries to talk to DNS server, which locate default at 127.0.0.53, for DNS resolving. Unfortunately, there is no one listen there, since the network namespace is isolate.
According to
man ip-netns
link, placing a independent file resolv.conf, at which explicit point to a nameserver, to/etc/netns/{nsName}/resolv.conf
solve the problemsBut, when I write my own code and execute a command inside the same network namespace seeing problems again. I can't tell the exact cause.
ip netns
could have read/etc/netns/{nsName}/resolv.conf
and bind mount it into namespace/etc/resolv.conf
. but I can't find related code on ip route2 git repoFinally, the compromise is replacing host
/etc/resolv.conf
default setting with my custom nameserver.OS&kernel:
Be careful:
/etc/resolv.conf
is controlled bysystemd-resolved.service
. And could be overwritten anytime.I can verified it by fire:
The text was updated successfully, but these errors were encountered: