LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-22-2008, 10:05 PM   #1
wstay
Member
 
Registered: Aug 2008
Posts: 61

Rep: Reputation: 15
Hosts file in /etc


Can someone please tell me what 127.0.1.1 in the /etc/hosts file refers to?
 
Old 12-22-2008, 10:25 PM   #2
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
It's localhost - see http://en.wikipedia.org/wiki/Localhost
 
Old 12-22-2008, 10:28 PM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
Don't you mean 127.0.0.1? It's the localhost loop back address for the same machine you are using. Some programs are written generically to communicate with components or a client via the network. If you are running the client part and the server part on the same machine, using the localhost address, the bottom of the network stack can be bypasses. Sometimes a network socket is used for interprocess communication.

Actually I think according to the standard, that 127.0.0.0 is a class one network for localhost. I'm not certain on this. I have seen "127.0.0.2 localhost" in /etc/hosts.
 
Old 12-22-2008, 10:28 PM   #4
ZAMO
Member
 
Registered: Mar 2007
Distribution: Redhat &CentOS
Posts: 593

Rep: Reputation: 30
There will not be 127.0.1.1 in /etc/hosts. If it exists just change it into 127.0.0.1.

127.0.0.1 localhost.localdomain localhost


special IP number (127.0.0.1) that is designated for the software loopback interface of a machine. 127.0.0.0 through 127.255.255.255 is also reserved for loopback and is used for internal testing on local machines.

It must be there irrespective you have a Ethernet card or not...
 
Old 12-22-2008, 10:34 PM   #5
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,275

Rep: Reputation: 126Reputation: 126
Quote:
Originally Posted by ZAMO View Post
There will not be 127.0.1.1 in /etc/hosts. If it exists just change it into 127.0.0.1.
Do not take this advice. The IP 127.0.1.1 is a valid entry in your /etc/hosts file, and it should correspond to the hostname of your computer.

Read section 10.4 at this link.

http://www.debian.org/doc/manuals/re...html#s-net-dns
 
Old 12-23-2008, 08:56 AM   #6
uks
Member
 
Registered: Jul 2007
Posts: 72

Rep: Reputation: 16
Yes, Quakeboy02 is correct.
You will in fact get a reply if you ping 127.0.1.1, even if you do not have this ip in your hosts file.
 
Old 12-23-2008, 01:14 PM   #7
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
Nothing wrong with the 1.1 as any 127* address references the local machine. Having multiple such IP addresses can be convenient when you want/need your localhost to be addressed in more ways than one. For example, one could resolve to "localhost", another to a fully qualified name, etc.

From the computer I am using right now:
127.0.0.1 localhost Selena
127.0.1.1 Selena.Arcturus.net Selena

@jschiwal
the 0.2 address is used by some spam filters.

Last edited by jay73; 12-23-2008 at 07:23 PM.
 
Old 12-23-2008, 02:03 PM   #8
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 164Reputation: 164
Quote:
Originally Posted by wstay View Post
Can someone please tell me what 127.0.1.1 in the /etc/hosts file refers to?
The local machine. All of 127/8 (and ipv6 ::1) refers to the loop back. Generally your hosts file will look something like:

Code:
127.0.0.1   localhost.localdomain   localhost
127.0.1.1   machine.domain.tld      machine
::1         ip6-localhost           ip6-loopback
By default after a new install. All 3 refer to the local machine.

It wouldn't be incorrect to change the secondary one to the true ip address of the local machine (if static) or remove it entirely. However, do not change it to 127.0.0.1 unless you know that is what you want. Generally speaking, you don't want to mess with it unless you have a specific reason.

Different distributions handle the 127.x.x.x addresses differently except for 127.0.0.1 typically. Just remember any 127/8 address refers to the local machine.

Last edited by rweaver; 12-23-2008 at 02:07 PM.
 
Old 12-24-2008, 02:03 AM   #9
ZAMO
Member
 
Registered: Mar 2007
Distribution: Redhat &CentOS
Posts: 593

Rep: Reputation: 30
Thanks for all. Its really a useful discussion with you guys...

Sorry for my wrong INfo.
 
Old 12-24-2008, 10:36 PM   #10
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
I was aware that 127.0.1.1 would refer to the local machine, but I don't think I have seen that pattern being used as the IP address for the FQDM of the local machine. Is this the convention of a certain distro, or is it based on an RFC?
 
Old 12-24-2008, 11:12 PM   #11
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
It appears to be a convenience introduced by Debian:
http://www.linuxquestions.org/questi...1-mean-623421/
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
hosts file Berticus Linux - Networking 2 03-05-2006 12:57 PM
hosts file? milesstandish Red Hat 2 11-02-2004 11:57 PM
PB with /etc/hosts file(s) ptreves Linux - Networking 0 09-10-2004 07:39 PM
does the /etc/hosts file work same as the M$ hosts file? Lleb_KCir Linux - Software 6 04-03-2004 05:33 PM
/etc/hosts File Crashed_Again Linux - Newbie 7 02-01-2003 01:04 AM


All times are GMT -5. The time now is 05:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration