Operating System - HP-UX
1833184 Members
3067 Online
110051 Solutions
New Discussion

Re: /etc/hosts question???

 
yank
Occasional Advisor

/etc/hosts question???

Hi!

May someone can explain, why I need line:
# HP Loopback
127.0.0.1 localhost loopback

at the /etc/hosts file? And I read, that I shouldn't change this string. Why?

Thank you for explanation!
6 REPLIES 6
eran maor
Honored Contributor

Re: /etc/hosts question???

Hi

127.0.0.1 localhost loopback
loopback is an internal address that uses the TCP stack, but no network card .

besacley the localhost and the loopback are the same and there are for internal network .

dont remove this line from the /etc/hosts .
love computers
Steven E. Protter
Exalted Contributor

Re: /etc/hosts question???

A bit of follow up to the great advice above.

There may be additional network information in the file that you can change if you know your network configuration.

loopback always gets used.

If network resolution isn't working based on the info in /etc/hosts it could be because you've set resolution to work elsewhere.

It is common to have a file called /etc/nsswitch.conf which can tell the server to resolve elsewhere first.

Here is mine and what it says.


hosts: dns[notfound=continue unavail=continue tryagain=continue] files

This means, look for network host resolution on a dns server first. then files, wich is /etc/hosts

dns resolution is controlled by what dns servers you machine uses, which could be but doesn't have to be itself.

Here is an example of the /etc/resolv.conf file which controls where your box looks for dns resolution.


[4243#] more /etc/resolv.conf
domain juf.net
nameserver 10.1.10.39
nameserver 10.1.10.45
nameserver 10.1.10.47

This says I'm part of domain juf.net and I look to three nameservers for hos resolution.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
paul courry
Honored Contributor

Re: /etc/hosts question???

In direct explanation of your question.....

localhost and loopback are aliases for the IP address 127.0.0.1. When a program or script refers to an alias it actually gets 127.0.0.1

127.0.0.1 is defined everywhere in the known universe as an IP address internal to your machine. This definition is part of the fabric of the universe along with the speed of light and why bread falls butter side down.
paul courry
Honored Contributor

Re: /etc/hosts question???

Forgot the Why..........

Touch that line and you may possibly screw up your machine forever. There are billions and billions of programs and scripts which use the alias localhost or loopback instead of the IP address 127.0.0.1

Remove it and all those programs and scripts stop working.
yank
Occasional Advisor

Re: /etc/hosts question???

Thank you for yours explanations!
But, when I use netstat -rn command I see two Interfaces Lo0 and Lan0(actually I had one - Lan0). What the Lo0 means (it's used by loopback, and has a biggest number of USE)?
The output is:

netstat -rn
Routing tables
Destination Gateway Flags Refs Use Interface Pmtu PmtuTime
127.0.0.1 127.0.0.1 UH 8 601 lo0 4608
192.168.20.61 127.0.0.1 UH 10 361827 lo0 4608
default 192.168.20.1 UG 0 4 lan0 1500
192.168.20 192.168.20.61 U 1 2536 lan0 1500
Ron Kinner
Honored Contributor

Re: /etc/hosts question???

Lo0 is your loopback interface. The one everyone is telling you not to mess with. As you have noticed it is a very popular interface. All of Paul's "...billions and billions..." of programs are busy using it. The loopback is used because it is an easy way to communicate from one process to another on the same machine without having to worry about messy things like how the memory is laid out. Traffic to the loopback interface travels down the TCP/IP stack like any other but before it hits the NIC it is shunted back up into the incoming stream.

lan0 is your real NIC. The lan = LAN part should be clear. The 0 comes because programmers don't count 1, 2, 3 like normal people but always start with 0.

Ron