3

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

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

1 Answer 1

3

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
2
  • 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. Nov 19, 2012 at 18:07
  • @DesmondHume - One works and the other does not.
    – Ed Heal
    Nov 19, 2012 at 18:11

You must log in to answer this question.

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