4 ms·
Can you explain the reasoning behind using 0.0.0.0 instead of 127.0.0.1? Genuinely interested.
by knocknock 11y ago
Can you explain the reasoning behind using 0.0.0.0 instead of 127.0.0.1? Genuinely interested.
- sergiotapia 11y agoBasically it's slower if you use 127 because it actually checks if something is running (example a server or whatever). 0.0.0.0 means explicitly "there is zilch, nip, nada". It's a little bit faster.
- jakeogh 11y agoNXDOMAIN is also an option if you use dnsmasq. I havent tested if 0.0.0.0 actually returns NXDOMAIN, but from you comment, it sounds like yes. Also see --dest-ip in "dnsgate config --help".
- ciupicri 11y agotelnet 0.0.0.0 $port works fine on my machine, it connects to localhost, so besides the speed, I don't think there's any other difference at least on Linux.
- lisivka 11y ago"ssh 0" or "ssh ::" works fine too. Also "http://0" http://0" or "http:// http://[::]".
- laumars 11y agoYou can have processes listen on 0 - which means all available IPv4 IPs (available to that machine). And since you can have processes listen on 0, it means you can equally curl 0; just like you could with 127.0.0.1. Here's an example from my IRC server (the only process I run on 0): $ curl https://0:9997 -kis | head HTTP/1.1 200 OK Date: Fri, 12 Feb 2016 07:49:24 GMT Server: ZNC - http://znc.in Content-Length: 1878 Content-Type: text/html Set-Cookie: 9997-SessionId=54245f15ba592bc691e09ac75e6778e6d4c33841fad71a8d6c56addc998e043f; path=/; Connection: Close <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> (just in case someone queries, 0 is just another notation of 0.0.0.0)
- Goopplesoft 11y agoIts in the repo's readme: https://github.com/StevenBlack/hosts#why-use-0000-instead-of-127001 https://github.com/StevenBlack/hosts#why-use-0000-instead-of...
- singlow 11y agoI do some blocking with my hosts file, and I used to put 127.0.0.1. That hits my default nginx vhost, so i usually get 404 or 403 pages which is not so bad since my default vhost is an empty docroot. But it is not very intuitive and sometimes I think a server is down because of the nginx error page before I realize its my hosts file. I considered making a custom error message for my default host to remind me what I'm hitting, but I'm lazy.
- jeswin 11y agoSecurity. I suppose it would be possible to craft a url that attacks local web services sometimes found on developer machines. If someone can confirm this is indeed the case, I'll submit a pull request to their README.
- nes350 11y agoThis won't work, at least on Chrome. It blocks all cross-domain requests to localhost[1]. Even if the target is used with a domain that resolves to 127.0.0.1, or has CORS completely disabled with "Access-Control-Allow-Origin: *". [1] https://code.google.com/p/chromium/issues/detail?id=67743 https://code.google.com/p/chromium/issues/detail?id=67743