Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Flow of DNS resolution query inside custom linux network namespace

My understanding for DNS resolution under ubuntu distribution.

  1. nsswitch.conf to get the location to look for.
  2. Go to each of the location & try to get the dns query resolved in the defined order. example entry: files mdns4_minimal [NOTFOUND=return] dns myhostname
  3. 'files' -> /etc/hosts to look for manual entries.
  4. mdns resolution for .local names inside broadcast/multicast network.
  5. DNS server
  6. hostname based resolution

Linux Network Namespace situation:

  1. I am able to ping IP addresses(local & after setting up default route) in custom NS.

  2. Not able to resolve dns queries like "dig google.com" because my host's resolve.conf has got nameserver as 127.0.0.53 which obviously is not anything inside network namespace.

  3. 'dig' command with @server is working fine. ex- dig @8.8.8.8 google.com

One working Solution:

Man Page of 'ip netns' suggests a priority order for DNS resolution as

  1. /etc/netns/NAME/

  2. /etc/ with 1 > 2 (dns resolution query resolving preference order)

My Questions:

  1. How to pass & dynamically configure DNS server address inside linux network namespace ? Do one always have to create a folder inside /etc/netns from host with elevated privileges.

  2. How the resolving order is decided ? Can a custom nsswitch.conf be passed to this new namespace ?

System's info:

beyond@beyond-GL552VW:/tmp$ uname -a 
Linux beyond-GL552VW 4.15.0-39-generic #42-Ubuntu SMP Tue Oct 23 15:48:01 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Please do correct me where ever above I have been wrong or might have missed something important.

Comments