Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have something like this in /etc/hosts:

192.168.0.1 example.com

192.168.0.1 *.example.com

example.com is pinged to 192.168.0.1 as expected but pinging say sub.example.com outputs:

unknown host sub.example.com

share|improve this question

migrated from stackoverflow.com Nov 19 '12 at 20:41

This question came from our site for professional and enthusiast programmers.

    
Did you try running man hosts from a terminal? –  cdhowie Nov 19 '12 at 18:00
    
@cdhowie Yes, just now. man hosts | grep '\(aster\|\*\)' outputs nothing useful. –  Desmond Hume Nov 19 '12 at 18:02
    
That's because the feature you're looking for doesn't exist. :) (At least not without running your own DNS server.) –  cdhowie Nov 19 '12 at 18:09
    
@cdhowie Ok, thanks. –  Desmond Hume Nov 19 '12 at 18:22
add comment

1 Answer

up vote 2 down vote accepted

You have answered your own question!

The /etc/hosts file is a one-to-one mapping between a hostname (not a collection of them) to a particular IP address.

Consider putting this into /etc/hosts file

127.0.0.1 *.com
share|improve this answer
    
Not sure if I answered my own question which actually was more about how to map all subdomains of a domain to an IP address, not a TLD to an IP. –  Desmond Hume Nov 19 '12 at 18:07
    
@DesmondHume - One works and the other does not. –  Ed Heal Nov 19 '12 at 18:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.