Isn't localhost simply 127.0.0.1 on Mac OS X 10.7 (Lion)?

9

I tried telnet localhost on Mac OS X Lion, and this is the output I got.

Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
Trying fe80::1%lo0...
telnet: connect to address fe80::1%lo0: Connection refused
telnet: Unable to connect to remote host: Connection refused

It tries three different addresses. I would have expected it to only try 127.0.0.1, or at least to try it first. What are these other addresses?

tony_sid

Posted 2012-03-28T23:39:40.313

Reputation: 11 651

FYI this behavior has been around a long time. You can peek in /etc/hosts to see the entries for localhost. – Dietrich Epp – 2012-03-29T06:03:05.400

Answers

14

127.0.0.1 is the (IPv4) localhost you are used to.

::1 is the IPv6 localhost address.

fe80::1%lo0 looks like a link-local IPv6 loopback address on the device lo0.

pgs

Posted 2012-03-28T23:39:40.313

Reputation: 3 153

7

::1 is IPv6 equivalent of 127.0.0.1

fe80::1 is link-local IPv6 address (one per adapter).

Josip Medved

Posted 2012-03-28T23:39:40.313

Reputation: 8 582

-1

Warning: Don't EVER run a telnet server on any system, always use sshd.

If your firewall goes down temporarily, even for a few seconds, there is a good chance someone can get in and hack your system.

When the world eventually moves to ipv6, many systems may be especially vulnerable as NAT and port forwarding won't offer any defence.

A telnet client however is useful for connecting to open ports for debugging.

Andy Lee Robinson

Posted 2012-03-28T23:39:40.313

Reputation: 908

1This doesn't address the question. Also it doesn't explain why a telnet server is bad (plain text). Just saying "Don't do X" without an explanation is not helpful. – Burhan Ali – 2012-04-07T09:34:25.743