What is the proper way to change the DNS IP?
I suspect that the name server provided by my ADSL modem/router is buggy. Whenever I browse to a website for the first time in ubuntu, resolving the domain name takes at least 15 seconds.
To work around that problem, I changed the nameserver configuration in /etc/resolv.conf
from 192.168.1.1 (my ADSL modem) to 8.8.8.8 (google's primary DNS). This seems to fix the problem, but unfortunately my changes to /etc/resolv.conf
are overwritten by "NetworkManager" at each startup.
What is the proper way to configure the name server IP in ubuntu 10.4?
If you have typical connection setup with the network manager and DHCP, try the following:
- Right click on the network manager icon in the panel and choose "Edit connections..."
- Select your connection from the wired or wireless tab, choose "Edit"
- (Enter your password if the connection is set as "system-wide available")
- Choose IPv4 settings tab
- Switch method to "Automatic (DHCP) addresses only"
- Enter the name server you want in the box "Additional DNS servers" and press "Apply"
That should do the trick.
The best way to set a nameserver via the CLI, without NetworkManger, with a static address, or independent of the connection is this:
Install the resolvconf package.
Run
sudo nano /etc/resolvconf/resolv.conf.d/head
(ignore the scary warning. /etc/resolv.conf is autogenerated, so the warning is there so it will get put in /etc/resolv.conf when /etc/resolv.conf is generated.) To the end of the file, add
nameserver <ip_of_nameserver>
Press Ctrl x and answer yes to saving the file. To finish up, regenerate /etc/resolv.conf so the changes are applied right now:
sudo resolvconf -u
You can change them like this.
First, click the network manager icon in your menubar, and the click the Edit Connections...
item.
Now, switch to the "Wired" or "Wireless" tabs, depending on what you use - I use WiFi, so I'll be using that.
Select the name of your network, and click Edit...
Switch to the IPv4 tab, and then change it from automatic DHCP to Automatic (DHCP) addresses only.
Enter in your DNS server IP address.
Click save, and you're done!
Another way to do this is to edit /etc/dhcp3/dhclient.conf
you can do this by typing this in to the run dialog (appears by pressing Alt + F2)
gksudo gedit /etc/dhcp3/dhclient.conf
Then find the following line
#prepend domain-name-servers 127.0.0.1;
And change it to
prepend domain-name-servers 8.8.8.8;
This will make dhclient (the DHCP client that NetworkManager uses) prepend this to your dns servers, so resolve.conf will end up looking like this
nameserver 8.8.8.8
nameserver 192.168.1.1
This solution will work everywhere and you will always get the DNS that you have chosen as the primary one.
Another solution is to change your router's configuration to use the other DNS server. Just log into its admin and as long as it's not the router causing the problem, all your client machines get better DNS.