Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 3 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .