In other words, if I put 127.0.0.1 example.com in my 'hosts', would or would not sub.example.com be still accessible?
Thanks
In other words, if I put 127.0.0.1 example.com in my 'hosts', would or would not sub.example.com be still accessible?
Thanks
Yes, but for different reasons than you probably think.
/etc/hosts can only resolve hosts, as the name indicates. Not domains.
But /etc/host.conf (by default) has
which tells the resolver library to first look into /etc/hosts, then query nameserver(s).Code:order hosts,bind
So, the request doesnt "go through" in a sense that /etc/hosts would be responsible for the domain. It just gets asked first.
That said, it is usually the better approach to keep all data in one place.
In this case the dns server config.
Simple answer is yes as the entries in the HOSTS file must match exactly. Using your example, example.com would match while everything else would not and the query would be sent to the DNS server.
Thank you for the responses. So the optimization I was hoping to achieve here* actually won't work? Oh well, Android phones will have to handle the whole list then. I appreciate your help.
* It won't even let me post a link to another thread on this forum. The thread can be found at www linuxforums org/forum/newbie/182630-filtering-out-lines-based-substrings.html#post860635 do note the missing dots in the site address.