School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!
Welcome to Dream.In.Code
Become an Expert!

Join 340,115 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 4,323 people online right now. Registration is fast and FREE... Join Now!



the Hosts file on Linux systems

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 offline

  • PHoToN PoWeR PaCK : not included
  • Icon
  • View blog
  • Group: Moderators
  • Posts: 15,043
  • Joined: 10-May 07


Dream Kudos: 2875

Expert In: Goofing Off

Post icon  Posted 17 January 2008 - 07: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
Was This Post Helpful? 0
  • +
  • -


#2 Tom9729  Icon User is offline

  • Segmentation fault
  • Icon
  • View blog
  • Group: Author w/DIC++
  • Posts: 2,279
  • Joined: 30-December 07


Dream Kudos: 425

Posted 12 April 2008 - 11:15 AM

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 offline

  • PHoToN PoWeR PaCK : not included
  • Icon
  • View blog
  • Group: Moderators
  • Posts: 15,043
  • Joined: 10-May 07


Dream Kudos: 2875

Expert In: Goofing Off

Posted 12 April 2008 - 11:19 AM

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

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users



Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month