howtothings.co.uk

Full Version: Setting DNS in Ubuntu
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
As has been mentioned here on several occasions using Google's Open DNS servers is a much better solution than using the DNS server provided by your ISP.

This is how to change your DNS setting in Ubuntu to use said Google DNS server using gedit as a text editor(substitute your editor of choice where gedit is used):

In a terminal:

sudo gedit /etc/resolve.conf

In order to use the Google DNS you will need to add two entries into the file as such:

nameserver 8.8.8.8
nameserver 8.8.4.4

Save the file

Now the only problem is the next time you reboot or restart your networking interface(s) your DNS servers will be reset by the system to use the settings given by the DHCP server. Since this is counter-productive to the task at hand we will write-protect the resolve.conf file using the following command in terminal

sudo chattr +i /etc/resolv.conf

This gives your resolv.conf file an immutable file attribute preventing anything from modifying it.
In turn if you ever decide you would like to change DNS servers again remember to use the following command before attempting to edit the file again:

sudo chattr -i /etc/resolv.conf

:tux
chattr? That some kind of chmod?

Good guide, most people never have any idea of where most config files for Linux are. Good that you know your stuff.
chattr is a command in the Linux operating system that allows a user to set certain attributes on a file residing on an ext2-based filesystem. If it's only ex2 that could be a problem as it's mostly ext3 on Linux installs now.

Nice tutorial none the less. I'm still getting complaints that people can't get on.
(14-09-2010, 11:43 PM)The Wing Wrote: [ -> ]chattr is a command in the Linux operating system that allows a user to set certain attributes on a file residing on an ext2-based filesystem. If it's only ex2 that could be a problem as it's mostly ext3 on Linux installs now.

Nice tutorial none the less. I'm still getting complaints that people can't get on.

Lol, nice quoting Wikipedia Mark, but have no fear. chattr was first implemented on ext2 because the file system had new "special" attributes added. chattr has worked on every iteration of ext since. Therefore there is NO problem using chattr if you have ext3 or ext4(which comes standard with Ubuntu 10.04.) That makes this tutorial widely applicable. :thumbs
Why thank you, i've never seen the use of chattr before so research was in hand. :tongue
You would be surprised how many tricks you learn when you have been using Linux based OSes for the last 14 years, and *nix for about twice that. Although I think based on the amount of activity on here that it is probably falling on deaf ears. Mark I think your Web Server's DNS or Web Server's ISP's DNS is having issues. There are A LOT of other websites on your server's IP address. If the web server isn't getting rdns proper for all the websites on that server then it is going to continue to be an issue. I think it is time to move again, unless someone at the web server gets off their ass and fixes it.
Bump! Now that the forum is back up people will actually get to see this.
I've just been setting up an Arch Linux box, and I was alerted of a new method to the chattr. If you append the following lines to your "/etc/dhcpcd.conf" file, you can tell your dhcpcd DHCP client not to overwrite the file.

Code:
nohook resolv.conf


Thanks for the guide. Setting up DNS can be tricky. I played around with open DNS, but have not set one up on my box. Do you guys think that running one locally is better than open DNS? If you are dealing with a large database, like www.myshipinfo.com, you may want to consider using multiple DNS servers, or going with a professional service.