Skip to content

feat: configure /etc/hosts#8

Open
yundantianchang wants to merge 1 commit intonlzy:masterfrom
yundantianchang:master
Open

feat: configure /etc/hosts#8
yundantianchang wants to merge 1 commit intonlzy:masterfrom
yundantianchang:master

Conversation

@yundantianchang
Copy link

Local hosts may have effects on hosts in network namespace.

@janedoe-lab
Copy link
Contributor

@yundantianchang , how hard it would be to modify it to alternatively accept local hosts file in case more than just localhost needs to be defined in /etc/hosts?

@nlzy
Copy link
Owner

nlzy commented Apr 14, 2024

Hi,

The configuration to /etc/resolv.conf and /etc/nsswitch.conf are necessary for DNS redirection. Especially on some systems that used systemd-resolved. Otherwise, DNS requests will not be sent to the 'fake gateway', and will not be handled by nsproxy.

But I don't know why /etc/hosts should be modified. Seems like doing some extra things but out-of-topic.

@yundantianchang
Copy link
Author

@nlzy, in "/etc/nsswitch.conf", there is a line "hosts: files dns". This means that dns queries will first use the "/etc/hosts" file and then "/etc/resolv.conf". However, if there are certain lines in "/etc/hosts" for the host to block certain domains, the application in nsproxy will use the same "/etc/hosts" file and will also be blocked. With this patch, nsproxy and the host are isolated, and the host's "/etc/hosts" file does not have any impact on applications in nsproxy.

@yundantianchang
Copy link
Author

@janedoe-lab, for the current codes, may need to edit the code directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants