LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Why ping hwy.local is not parsed into 127.0.0.1 ? (https://www.linuxquestions.org/questions/linux-networking-3/why-ping-hwy-local-is-not-parsed-into-127-0-0-1-a-4175576890/)

luofeiyu 04-07-2016 02:44 AM

Why ping hwy.local is not parsed into 127.0.0.1 ?
 
My os is debian8,here is the config file in my /etc/hosts
Code:

127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.0.1 hwy.local/wp
127.0.0.1 hwy.local/test

My local ip is 192.168.1.101 in local lan.
Code:

ping hwy.local/wp
PING hwy.local/wp (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.029 ms
^C
--- hwy.local/wp ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 3999ms
rtt min/avg/max/mdev = 0.029/0.034/0.037/0.002 ms
root@hwy:/home/debian8# ping hwy.local/test
PING hwy.local/test (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.114 ms
^C
--- hwy.local/test ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5000ms
rtt min/avg/max/mdev = 0.031/0.050/0.114/0.028 ms
root@hwy:/home/debian8# ping hwy.local
PING hwy.local (192.168.1.101) 56(84) bytes of data.
64 bytes from 192.168.1.101: icmp_seq=1 ttl=64 time=0.026 ms

Why ping hwy.local is not parsed into 127.0.0.1 ?
Why ping hwy.local is parsed into 192.168.1.101?

Ser Olmy 04-07-2016 05:16 AM

You're asking why a host name doesn't resolve to 127.0.0.1, even though there's no entry in the hosts file for the name in question?

Only /etc/hosts can be used to point names to a loopback address. (Well, I guess there's nothing preventing one from creating a A record in a DNS zone pointing to 127.0.0.1, but it wouldn't make much sense.)

Furthermore:
  1. It's not a good idea to have host names other than "localhost" resolve to the loopback address. It may result in some processes inadvertently binding to 127.0.0.1, and thus becoming isolated from the network.
  2. "hwy.local/wp" and "hwy.local/test" are not valid host names, as they contain a slash. If they're supposed to be URLs then they doesn't belong in /etc/hosts, since one cannot assign IP addresses to URLs, only to hosts.

dt64 04-08-2016 10:52 AM

What is the FQDN of your machine? Could it be you set it to hwy.local?
This would explain why the resolves its own name to its LAN address 192.168.1.101.


All times are GMT -5. The time now is 09:16 PM.