Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put wildcard entry into /etc/hosts?

Tags:

hosts

I recently wanted to point all subdomains for a test domain, let's say example.com to the localhost. Is there a way to point all requests on *.example.com to resolve to 127.0.0.1

like image 711
aamir Avatar asked Dec 07 '13 21:12

aamir


People also ask

How do you use wildcard in etc hosts?

Create a configuration to map the wildcard subdomains to the same IP. Restart the service. Create /etc/resolver directory. Create a custom DNS resolver where the file name is the domain name.

Can you add wildcard to hosts file?

1 Answer. Usually /etc/hosts file doesn't support any wild card entries.


1 Answers

It happens that /etc/hosts file doesn't support wild card entries.

You'll have to use other services like dnsmasq. To enable it in dnsmasq, just edit dnsmasq.conf and add the following line:

address=/example.com/127.0.0.1 
like image 55
aamir Avatar answered Sep 22 '22 01:09

aamir