Let 'localhost' be localhost
tools.ietf.org
tools.ietf.org
IPv4 loopback addresses are defined in Section 2.1 of [RFC5735] as "127.0.0.0/8".
That's not perfectly true. RFC5735 defines 127/8 as loopback addresses, but it leaves the door open for other addresses to be assigned to the loopback interface. And indeed doing so is a common pattern for network devices, and a less common (but very useful) pattern for services.
So let's say I've assigned 10.1.1.1/32 to a device loopback interface, I'm announcing it in my IGP, and I've bound a particular service to listen on 10.1.1.1:1234. Should the local resolver library be allowed to return 10.1.1.1 for servicename.localhost? Under this draft's (re)definition of loopback addresses, definitely not. So now we've lost that symbolic way to configure a service consumer to connect locally. You're left inventing workarounds such as your own namespace for loopbacks, or changing the service to also bind to, say, 127.1.1.1.
I also find it curious that this draft allows only address queries (presumably A and AAAA) under .localhost. I'd like to know the rationale for that restriction. For example, there may well be applications that only use SRV records.
Unnecessary restrictions can have unexpected & unknowable consequences. "Tools not policy".
16:04:25 speedy :{~} $ cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
10.1.1.1 servicelocalhostI don't mean to overconstrain the definition of loopback. If you have a good mechanism for specifying a specific IP range as loopback, and that mechanism can be understood by client software and resolution APIs, then I don't see any reason not to allow it.
The salient distinction from my perspective is traffic within a specific host, and traffic that traverses the network. If you have suggestions for language that make that distinction more clearly than the document currently does, I'm happy to incorporate it. :)
I also find it curious that this draft allows only address queries (presumably A and AAAA) under .localhost. I'd like to know the rationale for that restriction. For example, there may well be applications that only use SRV records.
https://twitter.com/dbrower/status/781001487157719040 raises similar concerns. The rationale is simple: I wanted to make the smallest change possible to RFC6761, and item 3 of https://tools.ietf.org/html/rfc6761#section-6.3 already contains the address query restriction.
It's probably reasonable to reconsider it, that's just a larger change than the one I was specifically trying to make. :)
Currently where it says "an IP loopback addresses", it may be worth saying something like "any of the IP loopback addresses for the device".
I agree that technically "an IP loopback address" ought to be sufficient, but I have also found it is a very common belief, probably even the majority belief, among people who use networking that "127.0.0.1" is the one and only loopback address. (I've lost count of the systems I've slightly broken just by feeding them 127.1.1.1 or equivalent.) I'm sure people who are the sort to read and write standards know better, but since it doesn't hurt the standard itself to emphasize the point, perhaps it's worth it.
There is none of this 127/8 mess.
"Name resolution APIs and libraries MUST recognize localhost names as special, and MUST always return a unicast address that cause the node to send an IP datagram to itself."
This deliberately echoes the language of RFC4291 and RFC6890 when defining loopbacks. Can I also suggest revising references, looks like RFC5735 has been obsoleted by RFC6890.
Overall I think this draft is a helpful clarification, thanks for creating it!
Did you just assume IPv4? That's IPist!
Seriously though. IPv6 exists. And it has a different address and notation for localhost (::1). Which means that using an IP(v4)-address alone is not guaranteed to be bulletproof.
The only bulletproof way to ensure that you bind to a genuine loopback interface is letting the OS tell you which address that is. And for that you need a "localhost" hosts-file entry or equivalent.
The next line in the document is "IPv6 loopback addresses are defined in Section 3 of [RFC5156] as '::1/128'." :)
Setting localhost to resolve to 10.1.1.1 works, sometimes, for this particular use case, but it doesn't work particularly well. Consider what happens when your served is multi-homed: which interface's address should "localhost" resolve to? What if you have one service at 10.1.1.1 and another at 192.168.0.1, both are on the same box, and both want to be called "localhost".
If you're single-homed, then why not bind INADDR_ANY and let localhost be 127.0.0.1?
It's a valid TLD...
https://www.icann.org/news/announcement-2-2014-08-01-en
shows why drive. was set to return 127.0.53.53.
Same thing happened with prod. and other TLD's. These are all names that were/are being used internally and now are valid TLD's that are going to cause issues for people :/
I don't understand this - you say you are "left with" an entire /8 that is universally recognized as the loopback ... what more could you want ?
I am genuinely curious - what is the utility of having lots of different network address ranges to define as the loopback ?
Our great-great-grandkids will still be troubleshooting the 'hey who deleted localhost from /etc/hosts' problem.
Personally, I set the host file to use https://github.com/StevenBlack/hosts in order to block ads on every computers I touch.
I also often use software that manage the host file and ignore the default physical file.
A novice was trying to fix a broken Lisp machine by turning the power off and on.
Knight, seeing what the student was doing, spoke sternly: “You cannot fix a machine by just power-cycling it with no understanding of what is going wrong.”
Knight turned the machine off and on.
The machine worked.
I develop my webserver locally, and it has many subdomains. So I have "www.localhost", "files.localhost", "doc.localhost", etc.
I have to add each subdomain to my /etc/hosts file before I can use it, as you can't have wildcards in that file. And even then, if I type a new one into Chromium, it will try and redirect me to a Google search result, unless I prefix the whole thing, eg "http://doc.localhost/"; once I do that and it connects, then the Omnibar will match the actual localhost entry easily going forward.
This should help anyone in a similar situation of testing their server with subdomains on localhost.
127.0.0.1.xip.io www.127.0.0.1.xip.io files.127.0.0.1.xip.io doc.127.0.0.1.xip.io
all resolve to 127.0.0.1
Shortcut to avoid being redirected to a search for uncommon TLDs: end with a /, no need for the http://.
You might as well set up domains for www.pocalhost, files.pocalhost, doc.pocalhost.
Or, why even have that part at all? You can just as easily set up the hosts record in /etc/hosts for www, and then visit http://www/ and it should work just fine on both Windows and Linux.
AFAICT current "best practice" for private networks is to use a private subdomain of your real domain. Say, .internal.example.com.
There are a lot of workarounds sure, but try explaining that to everyone else.
But for my machines, I just use a domain that I own.
related discussion:
http://serverfault.com/questions/17255/top-level-domain-doma...
Use a real domain name instead.
Why "hijacked" TLD? It would be a standard TLD.
If two orgs merge, and they both happen to use the same hostnames for some things, like say git.internal, they just refactor those hosts, or merge them since they merge.
Even if you're lucky, and it is git.internal - rather than source.internal with VSS on one and ClearCase on the other - there may be conflicting repository names. These'll be configured on developer's PCs, CI servers, automated deployment scripts. And that's just one domain name.
That's potentially a lot of work to connect two organizations: who may well not be connecting because of a merger - they may simply be contractors.
If ABC Corp and XZY Corp had their local stuff on internal.abc.com and internal.xyz.com, then all their old domains - and urls - keep working after they connect their networks. Whether and when to merge their services together becomes a decision based on the merits of each merge, rather than something that is forced because they choose a bad naming scheme.
Microsoft used to suggest using it for local networks, but now advise against it.
So ".localhost." means "every domain within the 'localhost' tld", not "every domain that contains the string 'localhost'".
Drafts are just that: drafts, not standards. They automatically expire after 6 months if not renewed. As stated in [1]: Internet-Drafts are working documents of the Internet Engineering Task Force (IETF), its areas, and its working groups. [...] Internet-Drafts are draft documents, and are valid for a maximum of six months. They may be updated, replaced, or obsoleted by other documents at any time.
edit: I don't really have any expertise or experience with this at all, just a thought.
I think reserving .localhost for loopback would be great for my workflow. Maybe it would check hosts for overrides before going straight to loopback?
So for example this would mean that if I put an entry for "server5.localhost 127.0.0.5" in my local DNS server then that entry can't be used, because the client's local resolver API will match *.localhost and it now "MUST NOT send queries for localhost names to their configured caching DNS server(s)" so it likely returns 127.0.0.1 instead of 127.0.0.5.
I think it also follows the spirit of the idea since the change is local to the machine you're using.
[1] https://developers.google.com/web/tools/chrome-devtools/debu...
If we are running distributed services, we know the machine that the code is run on is running. We can even reference this by many languages version of "this" keyword.
localhost is only "this" for IP4/6
nothing. the rfc talks only about the localhost tld.
Do I have to remap my whole localhost development in order to be able to access my localhost from a tablet?
Let me try wording this differently for you. "What if I develop something with only local calls between my front and back ends, and later I decide I want to test/implement a front-end feature on Android/iOS which doesn't support running the back end. Do I have to change my development so it is no longer local?" - the answer is yes.
On the other hand, "remap my whole localhost development" is a REALLY impressive-sounding way of saying "change the one line in the config file that says to connect to 'localhost' to connect to 'api.myhost.com' instead." Or maybe, if you are a sloppy developer, "use search-and-replace to replace all instances of 'localhost' in the code with 'api.myhost.com'." Either way, it is a trivial change.
It should be unaffected by the suggestion in this document.
Sad panda.
But it makes total sense.
Most networking code on Unix-like OSes should (eventually) boil down to something like a call to getaddrinfo(2), a system call that returns the set of addresses that match a query — typically a hostname. The result set for localhost will often include both ::1 and 127.0.0.1, but the result from the function also includes what type of address (IPv4 or IPv6, essentially) they are: you're supposed to take both the address (such as ::1) and the address family (such as IPv6) and pass them to socket(2). (and if that fails, try the next one in the list)
This mechanism lets you resolve domains that might be IPv4 or IPv6 only, and not even need to care in the code: if the domain is IPv4 only, then getaddrinfo only returns addrinfos w/ IPv4 addresses. Likewise for v6. You forward the information to socket(2) and connect(2), and don't ever need to deal with a concrete addrinfo object.
Back in the bad old days only a single user on a physical computer could log into a windows domain, because it was possible look up what user (singular) was on a host. Of course domain logins were also exquisitely sensitive to the nature of the network between client and server as well. It was a nightmare. Localhost is a product of that kind of thinking.
One-per-host resources that have to be shared across all users, security perimeters, vms, containers, etc. are an unwelcome headache. Of course, real systems don't actually share a localhost between all of these things, resulting in the even goofier concept of "which localhost do you mean?" That question was exactly why site-local addressing was deprecated from ipv6 https://tools.ietf.org/html/rfc3879
An actually portable standard for resolving well-known local entities would be great, but more special cases to try to fix the doomed localhost idea is a move in the wrong direction.
(And I am not sure this thinking will ever be dead, it's kind of extension of notion of "territory" for physical objects, and you can still pretty safely assume that whatever is in my home is my own.)