Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

use of 127.0.1.1 address?

265 views
Skip to first unread message

Pedro Valdez

unread,
Apr 29, 2016, 10:22:34 PM4/29/16
to
Looking at pages about /etc/hosts file, same say you should use
127.0.1.1 for the FQDN, so
127.0.0.1 = localhost but 127.0.1.1 = desktop01.localdomain
or whatever the PC is called.
So desktop01 is localhost, but these go to different numerical address.
Many such guides do not mention 127.0.1.1
It is used in Ubuntu, but not Red Hat derivatives.
Is is necessary?

J.O. Aho

unread,
Apr 30, 2016, 3:40:43 AM4/30/16
to
Traditionally the host file included a row like:

127.0.0.1 desktop01 desktop01.localdomain localhost localhost.localdomain

Seems like Debian decided to have only one to one mapping in their host
file and changed it to

127.0.0.1 localhost
127.0.1.1 dekstop01

It don't make much difference, for the 127.0.1.1 (or any other 127.*.*.*
address) will be the localhost.

As ubuntu hardly do anything themselves more than repack debian
packages, so changes in Debian ends up in ubuntu too.

Which ever works on all systems, it's just about taste.


--

//Aho

Bit Twister

unread,
Apr 30, 2016, 4:16:03 AM4/30/16
to
On Sat, 30 Apr 2016 09:40:41 +0200, J.O. Aho wrote:
>
> Traditionally the host file included a row like:
>
> 127.0.0.1 desktop01 desktop01.localdomain localhost localhost.localdomain

I thought the format was ip_address FQDN alias [ ..] which suggests
your example would be
127.0.0.1 desktop01.localdomain localhost.localdomain desktop01 localhost

Of course that causes problems when you ask hostname for the
alias/short name :(

> Seems like Debian decided to have only one to one mapping in their host
> file and changed it to
>
> 127.0.0.1 localhost
> 127.0.1.1 dekstop01.localdomain dekstop01

Yep, that fixes problem about hostname -s returning more than one alias.

I usually just bump the last octet value.
127.0.0.1 localhost.localdomain localhost
127.0.0.2 mail.home.test mail
192.168.11.132 wb.home.test wb

J.O. Aho

unread,
Apr 30, 2016, 10:52:03 AM4/30/16
to
On 04/30/2016 10:12 AM, Bit Twister wrote:
> On Sat, 30 Apr 2016 09:40:41 +0200, J.O. Aho wrote:
>>
>> Traditionally the host file included a row like:
>>
>> 127.0.0.1 desktop01 desktop01.localdomain localhost localhost.localdomain
>
> I thought the format was ip_address FQDN alias [ ..] which suggests
> your example would be
> 127.0.0.1 desktop01.localdomain localhost.localdomain desktop01 localhost
>
> Of course that causes problems when you ask hostname for the
> alias/short name :(
>
>> Seems like Debian decided to have only one to one mapping in their host
>> file and changed it to
>>
>> 127.0.0.1 localhost
>> 127.0.1.1 dekstop01.localdomain dekstop01
>
> Yep, that fixes problem about hostname -s returning more than one alias.

Something wrong with your hostname command? The hostname ain't taken
from the /etc/hosts but from /etc/hostname or alternative configuration
if your distribution don't use /etc/hostname.

--

//Aho

Richard Kettlewell

unread,
Apr 30, 2016, 11:10:14 AM4/30/16
to
The version in Debian uses uname(2). That is usually initialized from
/etc/hostname but hostname(1) doesn’t get it directly from the file.
AFAICS it’s also not capable of producing more than one name in response
to ‘hostname -s’.

--
http://www.greenend.org.uk/rjk/

Bit Twister

unread,
Apr 30, 2016, 11:27:19 AM4/30/16
to
On Sat, 30 Apr 2016 16:52:00 +0200, J.O. Aho wrote:
> On 04/30/2016 10:12 AM, Bit Twister wrote:
>> On Sat, 30 Apr 2016 09:40:41 +0200, J.O. Aho wrote:
>>>
>>> Traditionally the host file included a row like:
>>>
>>> 127.0.0.1 desktop01 desktop01.localdomain localhost localhost.localdomain
>>
>> I thought the format was ip_address FQDN alias [ ..] which suggests
>> your example would be
>> 127.0.0.1 desktop01.localdomain localhost.localdomain desktop01 localhost
>>
>> Of course that causes problems when you ask hostname for the
>> alias/short name :(
>>
>>> Seems like Debian decided to have only one to one mapping in their host
>>> file and changed it to
>>>
>>> 127.0.0.1 localhost
>>> 127.0.1.1 dekstop01.localdomain dekstop01
>>
>> Yep, that fixes problem about hostname -s returning more than one alias.
>
> Something wrong with your hostname command?

Nope.

> The hostname ain't taken from the /etc/hosts but from /etc/hostname
> or alternative configuration if your distribution don't use
> /etc/hostname.

Ooops, sorry. I thought -s and --alias were the same thing. My bad.
it is hostname --alias that would have the problem.

$ grep $(cat /etc/hostname) /etc/hosts
192.168.11.132 wb.home.test wb

$ hostname --alias
wb

add junk alias to /etc/hosts

$ grep $(cat /etc/hostname) /etc/hosts
192.168.11.132 wb.home.test wb junk

$ hostname --alias
wb junk

Vuk Vujovic

unread,
May 11, 2016, 3:19:51 AM5/11/16
to
On 04/30/2016 04:22 AM, Pedro Valdez wrote:
Hello,

I would like to add quick snap-in to this. In short explanation
127.0.0.1 is always localhost.
Now since distributions do not know do you have Internet or which kind
of internet do you have or is your internet even enabled they put
127.0.1.1 as FQDN of your machine.

That is just before you setup your network interface with public or LAN
IP address.

127.0.0.0 network is defined with netmask 255.0.0.0

So whatever you ping even 127.10.10.10 it will reply back from your
localhost interface.

For that purpose 127 A class subnet is used.

If there is networking and it uses LAN it will use
192.168.0.0/255.255.0.0 for example

If it is WAN it will use other IPs, but for loopback it will use
anything under 127.x.x.x

Hope this helps,
Regards,
Vuk.

0 new messages