Page 1 of 1

the Hosts file on Linux systems a begginers guide to networking systems on your lan Rate Topic: -----

#1 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5247
  • View blog
  • Posts: 27,066
  • Joined: 10-May 07

Post icon  Posted 17 January 2008 - 08:48 AM

Setting up your Hosts file:

Where this file comes from:
Back in the days of ARPANet each computer had a file which mapped out the location of the other computers. As time went on, more & more computers were added to this list. With the list growing came the possibility for other machines to become out of date. This is where DNS came in. However, we can still make use of this file & method today!

On your Linux system, you'll find this file in /etc/hosts. The basic hosts file contain at least the following:
127.0.0.1	   localhost



This allows you to communicate with 127.0.0.1 with the word 'localhost'. Go ahead & try it out for yourself!
$ping localhost

Any entry within the hosts file with a number sign (#) is considered a comment.

# Local Host
127.0.0.1	   localhost



The order to the hosts file is :

Quote

<IP Address> <host name> <alias>


So if you wanted to setup an internal webserver, & you wanted to access it using example, you could enter the following:


# Local Host
127.0.0.1	   localhost

# example web server
192.168.0.101 example



This will allow you to resolve example, to the given ip address.

# nslookup example
Server:		 192.168.0.2
Address:		192.168.0.2#53

Name:   example
Address: 192.168.0.101



The main drawback to using this method is you must 1st setup the ip addresses on each of the machines. Since DHCP stands the possibility of reassigning a new ip, this would cause your hosts file to become out of date.

For more information :
http://en.wikipedia....wiki/Hosts_file
http://www.linuxfrom...er07/hosts.html

Is This A Good Question/Topic? 0
  • +

Replies To: the Hosts file on Linux systems

#2 Tom9729  Icon User is offline

  • Segmentation fault
  • member icon

Reputation: 180
  • View blog
  • Posts: 2,641
  • Joined: 30-December 07

Posted 12 April 2008 - 12:15 PM

You can also use your hosts file to block bad domains.

For example:
127.0.0.1 microsoft.com


Was This Post Helpful? 0
  • +
  • -

#3 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5247
  • View blog
  • Posts: 27,066
  • Joined: 10-May 07

Posted 12 April 2008 - 12:19 PM

But before that can block the domains, you will have to clear your current DNS cache list.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1