Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to switch resolv.conf while switching namespace #37

Open
shekharHPE opened this issue Aug 6, 2019 · 2 comments
Open

Comments

@shekharHPE
Copy link

We have a resolv.conf file for every namespaces.
When switching from one namespace (say VRF_1) to another (say VRF_2), it seems that the resolv.conf file attached to VRF_1 is used to resolve the DNS instead of VRF_2.
Is there any way as of today to ensure use of a different resolv.conf while switching the namespace.

@ic2hrmk
Copy link

ic2hrmk commented Jul 13, 2020

Hi, I don't know is it still relevant. I tried two different ways:

  • to create resolv.conf under /etc/netns directory before creating the namespace OR forcing sudo resolvconf -u in netns after;
  • to add some wrapper on DNS Mask to handle dynamic changes with it.

The first one looks more natural, but I agree - both are workarounds

@thediveo
Copy link

  1. /etc/resolv.conf is an ordinary file, read by many DNS client libraries.
  2. As an ordinary file, /etc/resolv.conf is subject to mount namespaces, but not network namespaces.
  3. a process with a DNS client resolver library thus reads the /etc/resolv.conf from its currently active mount namespace, and if you don't change that to the one used by your boxed processes using separate different network and mount namespaces, your process uses the wrong /etc/resolv.conf.
  4. Switching a process into a different mount namespace is a point of no return and fails when your process is already multi-threaded.

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

No branches or pull requests

3 participants