0

I have Linux Mint 18, and always (with Linux Mint 17 too) have a problem with the connection to some repositories in the update option. The solution that I found is to run this in terminal and it works fine:

sudo echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf > /dev/null

But, I have to do this every time when I reboot or shutdown my PC.

I tried a lot of options from the internet to run this command on startup, but they don't work for me.

Any help?

  • Try to create a shell script (name it whatever.sh) under /etc/profile.d folder. Paste sudo echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf > /dev/null there. Reboot. It should work now. – ddnomad Aug 3 '16 at 18:20
  • i do, but don't work for me. I read similar answers before. I create script with text editor and save with sh extension, is this correct? the file dosn't header line to identify type file? – Linux Mint Newbie User Aug 3 '16 at 19:01
  • that's strange. Try to add #!/usr/bin/env bash to the first line (yet I doubt it would help). – ddnomad Aug 3 '16 at 19:12
  • don't work for me. Thank you so much for help me. – Linux Mint Newbie User Aug 3 '16 at 19:42
  • OMG; i can fix this!! 6 months with this problem!! every time run this command omg... I tell you what i do: – Linux Mint Newbie User Aug 3 '16 at 22:13
0

If you need the file never to be changed then you need to do this:

chattr +i /etc/resolv.conf

that means:

man chattr

chattr - change file attributes on a Linux file system
A file with the 'i' attribute cannot be modified:
  • i add: nameserver 8.8.8.8 to end of file of /etc/resolv.conf, and then do your step: s31.postimg.org/50xzd58vf/… – Linux Mint Newbie User Aug 3 '16 at 18:55
  • This works, however is not the best solution. The best solution is to ignore the DNS servers in the DHCP client. Some file systems do not support the +i attribute. – Rui F Ribeiro Aug 3 '16 at 19:05
0

In a simple and easy way, you can simply edit the "/ etc / network / interfaces" file, since it defines the file configuration "/ etc / resolv.conf" and defines the settings for the DNS Servers, as in this example :

# interfaces(5) file used by ifup(8) and ifdown(8)
# /etc/network/interfaces

auto lo 
iface lo inet loopback

dns-nameserver   8.8.8.8 
dns-nameserver   189.40.198.80
dns-nameserver   189.40.198.81

Of course here you will use the dns-nameserver you want and save the file, this will set the dns-nameservers to the local network of your machine automatically so you do not have to worry about resetting them again, and when you need to change the configuration just modify it again in the file "/ etc / network / interfaces". ok!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.