10 ms·
Let 'localhost' be localhost
- Aeolun 10y ago"Implementation Considerations: This change would make developers sad [...]" Sad panda. But it makes total sense.
- josegonzalez 10y agoMaybe someone should standardize internal TLD(s) for corporate and other use cases that would make developers less sad, as at least they have alternatives.
- phs318u 10y ago.local ? https://en.m.wikipedia.org/wiki/.local https://en.m.wikipedia.org/wiki/.local
- ibotty 10y agoUnfortunately that is less and less possible due to multicast DNS which hijacked that TLD.
- m_eiman 10y agoIsn't .private reserved?
- josegonzalez 10y agoYes, but that just means they can decide to do something special with it in the future, not that you can use it for your own purposes.
- jabl 10y agoLike the linked wikipedia article says, .local is used by mDNS(zeroconf/bonjour/avahi/etc.), so you might see weird stuff if you use it for a "normal" DNS environment. AFAICT current "best practice" for private networks is to use a private subdomain of your real domain. Say, .internal.example.com.
- tokenizerrr 10y agoGoogle registered the .dev gTLD for their internal use. So I've been doing the same, hijacking all requests for the .dev gTLD and serving up my own zones.
- noinsight 10y agoGoogle has both .dev and .prod.
- parenthephobia 10y agoThat's fine until Google buys your company. :)
- tokenizerrr 10y agoI am willing to take that risk. :)
- paulddraper 10y agoI will not be that sad.
- darfs 10y agoThat's why i use sometimes simply .loc.. :)
- tokenizerrr 10y agoThe annoying part is that Chrome treats valid (g)TLDs differently. If you type test.dev in your browser it will try to resolve test.dev. But if you type test.loc, it will google for test.loc. There are a lot of workarounds sure, but try explaining that to everyone else.
- amyjess 10y agoFYI, some Linux distributions default to .localdomain instead. But for my machines, I just use a domain that I own.
- DiabloD3 10y ago.local is for mdns only. I've been using .lan instead for locally poisoned DNS entries (in my case, dnsmasq being both DNS server and dhcpd to make it easy).
- lambda 10y agoNo, absolutely not. If people choose that for a local domain, that breaks mDNS.
- WorldMaker 10y agoIt would be great if mDNS was reliable enough that you wouldn't need to hack together a private DNS in most cases.
- tominous 10y agoBefore the gTLDs were expanded it was easy: just choose an unused word. These days I tend to see either subdomains of the main public domain, or a public domain registered solely for internal use.
- josegonzalez 10y agoThe proper way to do it, though it does mean that things such as using ssl for wildcard domains at an arbitrary level become difficult and potentially expensive.
- parenthephobia 10y agoIf they're internal domains you can run your own CA. No need to use wildcard certs or pay anything at all.
- Symbiote 10y agoAre there any reasons not to use a real domain?
- deleted 10y ago[deleted]
- y0ghur7_xxx 10y agoI agree with you. There should exist a standardized tld for internal networks that we can use and be sure that no one else has control over. Buying a domain and use a subdomain of that one is not a good workaround. .internal would be nice and is not used by now. I may go write an rfc now :) related discussion: http://serverfault.com/questions/17255/top-level-domain-domain-suffix-for-private-network http://serverfault.com/questions/17255/top-level-domain-doma...
- yrro 10y agoWhat happens as soon as two different organizations want to connect their networks together and they both turn otu to be using the same hijacked TLD? Use a real domain name instead.
- y0ghur7_xxx 10y ago> What happens as soon as two different organizations want to connect their networks together and they both turn otu to be using the same hijacked TLD? 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.
- parenthephobia 10y agoIt is not usually as easy as you suggest to just merge or refactor conflicting domains. 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.
- hlandau 10y agoPresumably single-letter TLDs will never be allocated. So you could allocate yourself one of those. Or maybe something with hyphens in not beginning with xn--.
- im4w1l 10y agoMaybe I'm overthinking this, but wouldn't a better solution be to say that server1.localhost doesn't have to be loopback, but that it must be resolved by asking the DNS server at localhost (or alternatively defined in the hosts file). edit: I don't really have any expertise or experience with this at all, just a thought.
- eksu 10y agoI think people already hosting their own DNS server at localhost don't need to worry about real domain allocations as they can spoof whatever they want for development. I think reserving .localhost for loopback would be great for my workflow. Maybe it would check hosts for overrides before going straight to loopback?
- LoSboccacc 10y agoisn't that the role of .localdomain tho?
- andreareina 10y agoIs there an actual case to be made for pointing localhost to anything other than the loopback device?
- stubish 10y agoOnly if you are intent on using a hack to produce an unmaintainable system. Making 'localhost' point to anything other than loopback is just asking for trouble. People will do it because they can, but not because they should.
- bsimpson 10y agoChrome on Android lets you bind your phone/tablet's localhost to your computer's localhost. This enables you to test during development, even if your corporate IT people disallow connections between devices on the same WiFi network (or partition personal devices onto a different network than corporate hardware).
- andreareina 10y agoHey that's a neat trick. If I'm reading the docs[1] correctly, as far as the application is concerned it is connected to the loopback. The same thing happens when I `ssh -L <port>:localhost:<port> <local-vm>`. 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/debug/remote-debugging/local-server?hl=en https://developers.google.com/web/tools/chrome-devtools/debu...
- bjackman 10y agoI'm not very networking-wise, got a question: is the "local machine" alwyas a well-defined thing? I'm thinking about stuff like where hosts are transparently distributed. Maybe there are systems out there that take advantage of resolving localhost to other than 127.* in order to make applications easy to transparently migrate when scaling servers out, or something?
- justincormack 10y agoNo, if your application is distributed, you won't be referring to localhost.
- kefka 10y agoAnd why not? 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
- andreareina 10y agoI think the GP meant that the client won't be calling on the server through 'localhost', at least not as a hard-coded parameter.
- EdwardDiego 10y agoWe have a reasonably distributed system. Localhost only ever occurs in a testing environment.
- noja 10y agoWhat happened to localdomain?
- inopinatus 10y agoIsn't there a problem here? This draft says: 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".
- ghshephard 10y agoSymbolic way to force a local application locally as follows: 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 servicelocalhost
- mikewest 10y agoThat'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. I 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 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 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. :)
- bcoates 10y ago-1 from me. 'localhost' is an artifact of a model of network computing that is no longer relevant; it's a special case of the general antipattern of network-topology sensitive design. 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 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.
- js8 10y agoI guess the authors understand that "localhost" is not an ideal authentication mechanism, however, the fact is that many application do use it as such. And the reason why they decided to come up with the RFC, to at least fix this on the level of DNS resolvers. (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.)
- mobiuscog 10y agoCouldn't we just define 'loopback' instead ?
- 0x0 10y agoThere are several "localhost.<tld>" domains in the wild today. What happens to those?
- y0ghur7_xxx 10y ago> There are several "localhost.<tld>" domains in the wild today. What happens to those? nothing. the rfc talks only about the localhost tld.
- 0x0 10y agoAh, you're right. Thanks for clarifying.
- amingilani 10y agoJust so we're clear. All these domains would just go away? https://iwantmyname.com/?domain=localhost https://iwantmyname.com/?domain=localhost
- throwanem 10y agoNo. This draft describes a change by which localhost becomes effectively a new TLD in which all names map to the loopback address. Names in other TLDs won't be affected.
- sohkamyung 10y agoSorry to nitpick, but this is technically a Draft, not a RFC. 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. - [1] https://datatracker.ietf.org/submit/ https://datatracker.ietf.org/submit/
- conjectures 10y agoHas Theresa May got a role in the IETF as well? :)
- gant 10y agoI always thought it made sense to address local VMs with .localhost domains in my hostsfile. Apparently not?
- drostie 10y agoYou can address them with whatever domains you choose; suffixing them with .localhost is no better than suffixing them with .local, .loc, .qwyjibo, or not suffixing them at all: these are merely personal choices you made to give the domains some look and feel, but they aren't intrinsically privileged by the system.
- andreareina 10y agoI've taken to having my VMs support mDNS (specifically avahi on Debian), and I can connect to <hostname>.local without adding an entry to my hosts file or messing with DNS.
- lambda 10y agoI have had a number of customers who have broken our applications, which have daemons listening on localhost, by editing their /etc/hosts files and removing the localhost entry. I guess various people edit /etc/hosts to prevent applications from talking to licensing servers, and in the process happen to accidentally blow away the localhost entry (since these customers don't know what they're doing). We had this happen enough that we eventually stopped using "localhost" and started using 127.0.0.1 in our code.
- okket 10y agoLooks like we need eternal IPv4 support, if it is just for 127.0.0.1 :(
- theandrewbailey 10y agoI was expecting IPv4 to be around forever, for similar reasons that COBOL and the still emulated 8254 PC beep are: there's too much critical infrastructure using it.
- drzaiusapelord 10y agoHonestly, when could we ever retire IPv4? We've had, what three or four decades now, of building the world's infrastructure on it. What's a realistic scenario to retire that stuff even if everyone gets on IPv6 in 10 years. Another 50 years? 100? 500? Our great-great-grandkids will still be troubleshooting the 'hey who deleted localhost from /etc/hosts' problem.
- Raphmedia 10y agoWhile some people might edit their host for nefarious purposes, I think it's wrong to attribute all of it to malice. Personally, I set the host file to use https://github.com/StevenBlack/hosts 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.
- 10y ago
- byuu 10y agoNice! I'm very much in favor of this change. 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/"; 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.
- Scarblac 10y agoI wish whoever owns localhost.org (which resolves to 127.0.0.1) configured it so that *.localhost.org also worked. Would help with the browsers too.
- imtringued 10y agoYou can use xip.io 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
- yaur 10y agoI use 42foo.com which does exactly that.
- warp 10y agoThere is also lvh.me
- yeezul 10y agoWhat if I develop something on localhost, and two months later I decide I want to test/implement a feature on Android/iOS. Do I have to remap my whole localhost development in order to be able to access my localhost from a tablet?
- mcherm 10y agoYes. 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.
- rgacote 10y agoAnd please make it 127.0.0.1 and not ::1. I've found several instances where localhost resolved to ::1.
- ciupicri 10y agoUse localhost4 & localhost6 if you don't want that kind of surprises.
- deathanatos 10y agoIt resolves to both on most major OSs, and I think it should as long as something isn't horribly misconfigured. 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.
- Steeeve 10y agoOn a related note, few things annoy me more than when my browser updates localhost to www.localhost.com.
- the8472 10y agoin firefox you can set browser.fixup.alternate.enabled = false
- zrm 10y agoIt seems like the problem with doing this is that there are multiple localhost IPs. If it was as simple as "every A query for [any].localhost is 127.0.0.1, every AAAA query is ::1" then it would be one thing, but the A query could also be 127.0.0.2 etc. 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.
- devnull42 10y agoThis seems like a bad idea. It seems to be solving for a problem that doesn’t exist while introducing the potential for issues. If you want to prevent latency or lookups localhost should just live in the hosts file.
- bsimpson 10y agoHow would this affect Chrome on Android, which allows you to redirect localhost requests from a phone to access localhost on the computer it's tethered to?
- mikewest 10y agoThat's done via port-forwarding. That is, Chrome is talking to the loopback interface on a particular port. The server listening at that port forwards the requests across the debugging bridge to the phone, and ferries the response back across in the same way. It should be unaffected by the suggestion in this document.
- textmode 10y agoWhen you control your own cache you can set .localhost to whatever you want. Not necessarily true if you cede control of your DNS resolution to a third party. I would not trust DNS resolution libraries embedded in applications that cannot easily be changed or removed. Especially if they ignore /etc/hosts or point users toward third party caches. Think of your own cache as a HOSTS file that accepts wildcards.
- rburhum 10y agoThe folks at Tucows are going to get pissed off ;) https://who.is/whois/localhost.com https://who.is/whois/localhost.com
- xg15 10y agoI think for non-DNS experts (like me) it's important to know that in DNS terminology, the notation "tld." is used to donate top-level domains. (Note the trailing period) So ".localhost." means "every domain within the 'localhost' tld", not "every domain that contains the string 'localhost'".