School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 298,482 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,778 people online right now. 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 - 07: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 - 11:15 AM
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 - 11:19 AM
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: 11/3/09 11:39PM

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