Rob Golding

Technology Consultant
  • Home
  • About Me
  • Curriculum Vitae
  • Contact

The Hosts File in Ubuntu

November 26, 2008

In my last post, I talked about configuring Ubuntu for use with different proxy servers, and something became quite evident. It would have been nice to have a way of aliasing the IPs of those servers, so instead of typing the number out, one could simply type “proxy”, for example.

This can be easily achieved using the hosts file, which is present on both linux and windows operating systems. Here I will discuss how to use the hosts file in Ubuntu linux.

First, you must gain access to the file. It can only be written to as root, so the sudo command must be used, in conjunction with your favourite editor. For example:

sudo gedit /etc/hosts

As you can see, the hosts file is located at /etc/hosts.

To add entries to the hosts file, simply add another line at the end, following the president set by the one or two lines alreay present. The syntax is basic, and consists of the IP to be aliased, then the name that you would like to alias it with. For example, the proxy in my last post could be entered as follows:

128.243.253.119    proxy

As it happens, this is actually a surprisingly effective method of blocking malicious websites, and even adverts. Quite simply, any domain that you would not like your browser to access, can be added to the hosts file with an IP of 127.0.0.1. This is the IP address for the local machine you are currently working on. For a huge list of such websites, check out www.someonewhocares.org/hosts. Simply copy and paste the file on that site into your hosts file, and you’re set. It should be noted that this will work on windows, Mac or linux. On Windows XP/Vista the hosts file is located in:

C:\Windows\system32\drivers\etc\hosts

Obviously if your Windows installation is on a different drive, simply replace C: with the relevant letter.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Slashdot
  • StumbleUpon
  • Technorati
Categories
Linux, Technology
Comments rss
Comments rss
Trackback
Trackback

« Ubuntu and The University of Nottingham’s Proxy Dell Studio Laptop Wakes Itself up from Hibernate »

Leave a Reply

Click here to cancel reply.

Pages

  • About Me
  • Curriculum Vitae

RSSFollow Me

Rob Golding
  • I've lost my car under all this white stuff...I'm sure it will turn up soon. 10:57:50 AM February 21 from HTC Peep
  • @BenJenkinson I certainly do! Everyone but Simon and River. 07:32:19 PM February 07 from HTC Peepin reply to BenJenkinson
  • Is it sad that my servers are now all named after firefly characters? 12:58:30 PM February 07 from HTC Peep

Recent Posts

  • Mercurial on University of Nottingham Computer Science Servers
  • Custom Section Numbering in LaTeX
  • Linux-Windows Integration (à la Likewise-Open & Winbind)
  • It Begins…
  • Exchange 2007 Autodiscover Issues

Archives

  • March 2010
  • February 2010
  • December 2009
  • September 2009
  • July 2009
  • June 2009
  • April 2009
  • March 2009
  • January 2009
  • November 2008
  • October 2008
  • September 2008
  • July 2008
  • April 2008
  • February 2008
  • January 2008
  • December 2007
  • November 2007
  • October 2007
  • September 2007

Technorati

Blog Information Profile for robgolding63
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox