If I want to add an entry to /etc/hosts
to resolve all traffic for example.com
to 1.2.3.4
, do I need to add
1.2.3.4 example.com
1.2.3.4 www.example.com
1.2.3.4 smtp.example.com
1.2.3.4 pop.example.com
...
Or will just adding
1.2.3.4 example.com
suffice?
Best Answer
You will need to specify each and every subdomain. If that is not what you want, you should look into installing a real DNS server (e.g. bind9).
This is rather easy to check by first adding just
example.com
to/etc/hosts
and then doThe first will succeed with the provided IP address. The second will go to
93.184.216.119
(the IP address in the internet for www.example.com)