Wildcard /etc/hosts file? ie) 192.168.1.2 *.example.com

If your problem doesn't fall into one of the other categories, report it here.

Moderator: Moderators

Post Reply
vask
Posts: 45
Joined: Tue Jul 21, 2009 4:33 pm

Wildcard /etc/hosts file? ie) 192.168.1.2 *.example.com

Post by vask »

I have a staging sever and I want all gargoyle wireless clients to automatically resolve ALL subdomains of example.com to 192.168.1.2

All other DNS queries can be resolved normally

If I make a new subdomain I do not want to to have to add it to the configuration. ie)
vi /etc/hosts
192.168.1.2 new-subdomain.example.com

Please Advise
Last edited by vask on Wed Oct 09, 2013 6:11 am, edited 1 time in total.

vask
Posts: 45
Joined: Tue Jul 21, 2009 4:33 pm

Re: Wildcard /etc/hosts file? ie) 192.168.1.2 *.example.com

Post by vask »

Solved by adding a single line in the dnsmasq config. Just ssh into the gargoyle router and do:

vi /etc/dnsmasq.conf

Code: Select all

address=/example/192.168.1.2
Then reboot the the gargoyle router and test

More Info
------------------------------------

man dnsmasq

Code: Select all

-A, --address=/<domain>/[domain/]<ipaddr>
    Specify an IP address to return for any host in the given domains. Queries in the domains are never forwarded and always replied to with the specified IP address which may be IPv4 or IPv6. To give both IPv4 and IPv6 addresses for a domain, use repeated -A flags. Note that /etc/hosts and DHCP leases override this for individual names. A common use of this is to redirect the entire doubleclick.net domain to some friendly local web server to avoid banner ads. The domain specification works in the same was as for --server, with the additional facility that /#/ matches any domain. Thus --address=/#/1.2.3.4 will always return 1.2.3.4 for any query not answered from /etc/hosts or DHCP and not sent to an upstream nameserver by a more specific --server directive.
I don't think this is possible from the web interface ie) http://192.168.1.1

Post Reply