Rob Golding

Technology Consultant
  • rss
  • Home
  • About
  • RSS
  • 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
Uncategorized
Comments rss
Comments rss
Trackback
Trackback

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

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)

You must read and type the 5 chars within 0..9 and A..F, and submit the form.

  

Oh no, I cannot read this. Please, generate a

Pages

  • About
  • RSS

Navigation

  • Active Directory Feed for all posts filed under Active Directory
  • Exchange Feed for all posts filed under Exchange
  • Home Network Feed for all posts filed under Home Network
  • Life Feed for all posts filed under Life
  • Linux Feed for all posts filed under Linux
  • Technology Feed for all posts filed under Technology
  • Uncategorized Feed for all posts filed under Uncategorized
  • Virtualization Feed for all posts filed under Virtualization
  • VMware Feed for all posts filed under VMware
  • Web Development Feed for all posts filed under Web Development
  • Windows Server Feed for all posts filed under Windows Server

Archives

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

Recent Posts

  • Bullet Bitten: VMware Server 2.0
  • Dell Studio Laptop Wakes Itself up from Hibernate
  • The Hosts File in Ubuntu
  • Ubuntu and The University of Nottingham’s Proxy
  • Upgrading to Ubuntu 8.10 (Intrepid Ibex)

Technorati

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