0

How can I change my nameserver but WITHOUT changing any file by hand, which command do I need to use for it?

root@ubuntu-1gb-nyc2-01:~# cat /etc/resolv.conf 
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8
nameserver 8.8.4.4
root@ubuntu-1gb-nyc2-01:~# 
alexus
  • 155
  • 1
  • 5
  • 13

1 Answers1

1

If you're going to always use the same nameserver (ie: you're not on a laptop or other mobile device) and want a permanent solution, you can try the following:

Set /etc/resolve.conf as Immutable

  1. Edit /etc/resolve.conf
  2. Set /etc/resolve.conf as immutable
    • sudo chattr +i /etc/resolve.conf

Remove /etc/resolve.conf Immutable

No program will be able to change the contents of your /etc/resolve.conf file, unless your remove the immutable flag:

  1. sudo chattr -i /etc/resolve.conf
earthmeLon
  • 11,247
  • I'm not looking into making that change permanent, I just need to be able to run a command and specify nameserver. Is there a way to do so via command? – alexus Feb 19 '16 at 17:47