3 ms·
Does this mean Firefox will ignore my hosts file entry? 127.0.1.12 dev.localhost
by rascul 6y ago
Does this mean Firefox will ignore my hosts file entry?
127.0.1.12 dev.localhost
- bzbarsky 6y agoBased on code inspection, I believe so, yes. It will map "dev.localhost" to 127.0.0.1.
- rascul 6y agoI wonder if Mozilla overlooked this. IANA has 127.0.0.0/8 reserved for loopback, not just 127.0.0.1. https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml https://www.iana.org/assignments/iana-ipv4-special-registry/...
- gpvos 6y agoYes, but that's only relevant if Firefox were mapping from IP addresses to something. Here it's mapping to an IP address, so 127.0.0.1 is fine (even though, e.g., 127.0.0.42 would also have been fine).
- rascul 6y agoIt seems relevant because Firefox ignores that I might have dev.localhost mapped to a valid loopback address that is not 127.0.0.1.
- gpvos 6y agoThanks, this was enlightening.
- Seb-C 6y agoTo have clean URLs I have in the past had a setup like this, which won't be possible anymore: http://foo.localhost/ -> 127.0.0.1:80 http://bar.localhost/ -> 127.0.0.2:80 This way you can have multiple services running on the default ports.
- bzbarsky 6y agoWhat Mozilla is implementing here, I suspect, is RFC 6761 section 6.3 item 3, which says: Name resolution APIs and libraries SHOULD recognize localhost names as special and SHOULD always return the IP loopback address for address queries and negative responses for all other query types. Name resolution APIs SHOULD NOT send queries for localhost names to their configured caching DNS server(s). A few notes: 1) The use of "the IP loopback address" is a bit weird in IPv4, of course. 2) It's hard to know which loopback address to return from an API without violating the "SHOULD NOT" part of this item. There's really no way to win here. In theory Firefox could do the resolution as normal and then if it doesn't come back as loopback replace it with 127.0.0.1. That would be perfectly within the letter of the RFC, since none of the stuff above it MUST-level requirements, but probably not really within its spirit, since it would violate the "SHOULD NOT" bit. Note that Firefox is not alone here; Chrome has the same behavior last I checked. https://bugzilla.mozilla.org/show_bug.cgi?id=1220810#c28 https://bugzilla.mozilla.org/show_bug.cgi?id=1220810#c28 is a comment from one of the networking/security folks at Chrome about this precise issue, in case it's of interest.
- rascul 6y ago> There's really no way to win here. In theory Firefox could do the resolution as normal and then if it doesn't come back as loopback replace it with 127.0.0.1. That would be perfectly within the letter of the RFC, since noneo f the stuff above it MUST-level requirements, but probably not really within its spirit, since it would violate the "SHOULD NOT" bit. Could a check to see if the name is "localhost" or "*.localhost" suffice to satisfy the "SHOULD NOT" requirement? From the bugzilla comment: > It seems reasonable to extend that to support any /etc/hosts assertions that fall into 127.0.0.0/8, but that's not something we've heard a whole lot of interest in, though there have certainly been one-off requests. That does seem reasonable to me, and it covers more than just "localhost" names. I do understand that most uses probably do not require resolution of localhost names to other than 127.0.0.1. I may also be a little annoyed that I'll have to make some changes to something I've been doing for a long time. Thank you for your research and your replies.
- bzbarsky 6y ago