Welcome to Dream.In.Code
Getting Help is Easy!

Join 107,398 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,196 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



the Hosts file on Linux systems

 
Reply to this topicStart new topic

> the Hosts file on Linux systems, a begginers guide to networking systems on your lan

no2pencil
Group Icon



post 17 Jan, 2008 - 08:48 AM
Post #1


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:
CODE

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.

CODE

# 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:


CODE

# 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.

CODE

# 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.org/wiki/Hosts_file
http://www.linuxfromscratch.org/lfs/view/s...er07/hosts.html
Go to the top of the page
+Quote Post


Register to Make This Ad Go Away!

Tom9729
Group Icon



post 12 Apr, 2008 - 12:15 PM
Post #2
You can also use your hosts file to block bad domains.

For example:
CODE

127.0.0.1 microsoft.com
Go to the top of the page
+Quote Post

no2pencil
Group Icon



post 12 Apr, 2008 - 12:19 PM
Post #3
But before that can block the domains, you will have to clear your current DNS cache list.
Go to the top of the page
+Quote Post


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 8/28/08 04:12PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month