The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,808 other followers

127.0.1.1 in /etc/hosts for your hostname?

Posted by jpluimers on 2017/04/07

Coming from an OpenSuSE background, I was a bit surprised to find 127.0.1.1 in the /etc/hosts file to point to the hostname in Raspbian distributions.

It means you have to change at least these files when altering the hostname:

/etc/hosts
/etc/hostname

In addition to those, I also changed these:

/etc/ssh/ssh_host_rsa_key.pub
/etc/ssh/ssh_host_ecdsa_key.pub
/etc/ssh/ssh_host_dsa_key.pub
/etc/ssh/ssh_host_ed25519_key.pub
/etc/.git/description

After altering these files, you want to run this (via: Pi Town: Change a Raspberry Pi’s Hostname without Rebooting [WayBack])

sudo /etc/init.d/hostname.sh start

This prevents In order to prevent messages like sudo: unable to resolve host raspberrypi without rebooting.

The 127.0.0.1 seems to be a Debian thing: Chapter 5. Network setup – 5.1.1. The hostname resolution [WayBack] has

The IP address 127.0.1.1 in the second line of this example may not be found on some other Unix-like systems. The Debian Installer creates this entry for a system without a permanent IP address as a workaround for some software (e.g., GNOME) as documented in the bug #719621.

The <host_name> matches the hostname defined in the “/etc/hostname“.

For a system with a permanent IP address, that permanent IP address should be used here instead of 127.0.1.1.

For a system with a permanent IP address and a fully qualified domain name (FQDN) provided by the Domain Name System (DNS), that canonical <host_name>.<domain_name> should be used instead of just <host_name>.

via: linux – Why does my hostname appear with the address 127.0.1.1 rather than 127.0.0.1 in /etc/hosts? – Server Fault [WayBack]

There isn’t a great deal of difference between the two; 127/8 (eg: 127.0.0.0 => 127.255.255.255) are all bound to the loopback interface.

The reason why is documented in the Debian manual here:http://www.debian.org/doc/manuals/debian-reference/ch05.en.html#_the_hostname_resolution

Ultimately, it is a bug workaround; the original report is here: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=316099

–jeroen

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: