Search code examples
linuxdnsdnsmasqnetworkmanager

Reproduce `Temporary failure in name resolution`


How can I reproduce manually the Temporary failure in name resolution error, when doing ping google.com in linux?

Probably, I can add a broken DNS server by my own and specify it in /etc/resolv.conf?

I need this for testing my project.


Solution

  • You can try this in /etc/nsswitch.conf:

    hosts:          files
    

    That is remove all traces of the dns service for the hosts case (a normal line is something more like hosts: files dns but have a look at yours before changing it).

    Then, if a name/IP is in /etc/hosts the name resolution works, if it is not, it does not work as the DNS is not consulted.