Find the answer to your Linux question:
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.
  1. #1
    Just 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

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,444
    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
    Code:
    order hosts,bind
    which tells the resolver library to first look into /etc/hosts, then query nameserver(s).

    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.

  3. #3
    Linux Guru Lazydog's Avatar
    Join Date
    Jun 2004
    Location
    The Keystone State
    Posts
    2,677
    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.

    Regards
    Robert

    Linux
    The adventure of a life time.

    Linux User #296285
    Get Counted

  4. $spacer_open
    $spacer_close
  5. #4
    Just 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •