Debian/Kali – Problem with writing to /etc/resolv.conf

7,177

If your /etc/resolv.conf is autogenerated by NetworkManager, it will be overwritten at many network events like DHCP-Requests. This is done by the resolvconf package. See man resolvconf (head and tail files) for persistent change of the resolv.conf.

Share:
7,177

Related videos on Youtube

EvenDance
Author by

EvenDance

Updated on September 18, 2022

Comments

  • EvenDance
    EvenDance over 1 year

    I want to connect to a public DNS Server (in this case Google's) by modifying the /etc/resolv.conf (which is automatically generated by NetworkManager). If I edit the content of the file via gedit /etc/resolv.conf to

    nameserver 8.8.8.8
    nameserver 8.8.4.4
    

    (which are the IPs of Google's public DNS server), everything works fine and I do not even have DNS leaks, but if I run my Script:

    #!/bin/sh
    echo "nameserver 8.8.8.8" > /etc/resolv.conf
    echo "nameserver 8.8.4.4" >> /etc/resolv.conf
    

    It does not work and I have no Internet-Connection at all.

    • EvenDance
      EvenDance over 7 years
      There is no error message, the script changes the resolv.conf like I want to the same thing I do via gedit, I just do not have an internet connection afterwards...:(
    • Vafa
      Vafa over 7 years
      Could you please post the output of following commands : ifconfig -a and netstat -rn
    • Anthony Geoghegan
      Anthony Geoghegan over 7 years
      It would be useful to edit your question to show the result of cat /etc/resolv.conf when it's working before you run your script and after your script has run (when it's broken).
    • roaima
      roaima over 7 years
      When you "have no Internet Connection" do you really mean that? What is then the result of running ping -c4 8.8.8.8? If you get no result please post the output of netstat -rn. But add these answers to your question; do not put them here in comments.