I am just learning using Ubuntu and when I tried to configure the DNS, I need to deal with something call localhost, loopback interface. Can anyone explain me the differences between them and the meaning of the addresses 127.0.0.1 and 127.0.1.1, when should I use 127.0.0.1 and when should I use 127.0.1.1

As your machine gets started, it will need to know the mapping of some hostnames to IP addresses before DNS can be referenced. This mapping is kept in the /etc/hosts file. In the absence of a name server, any network program on your system consults this file to determine the IP address that corresponds to a host name.

The loopback device is a special, virtual network interface that your computer uses to communicate with itself. It is used mainly for diagnostics and troubleshooting, and to connect to servers running on the local machine.

the loopback is interface lo and ip 127.0.0.1 by default

127.0.0.1 localhost

Debian than ubuntu choose to define 127.0.1.1 for mapping the ip of your host_name in case that you have no network

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.

127.0.1.1 host_name

It doesn't really mean anything in particular (it's just another IP in the 127.0.0.0/8 block).

The reason it's used as the IP for your hostname is explained in Section 10.4 of the Debian Reference Manual.

Quote:

Some software (e.g., GNOME) expects the system hostname to be resolvable to an IP address with a canonical fully qualified domain name. This is really improper because system hostnames and domain names are two very different things; but there you have it. In order to support that software, it is necessary to ensure that the system hostname can be resolved. Most often this is done by putting a line in /etc/hosts containing some IP address and the system hostname. If your system has a permanent IP address then use that; otherwise use the address 127.0.1.1.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.