Results 1 to 4 of 4
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...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 09-13-2011 #1Just Joined!
- Join Date
- Sep 2011
- Posts
- 4
Does DNS resolving for subdomains go through the main domain?
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
- 09-13-2011 #2
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.You must always face the curtain with a bow.
- 09-14-2011 #3
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.
- 09-15-2011 #4Just Joined!
- Join Date
- Sep 2011
- Posts
- 4
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.


Reply With Quote
