Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dnsmasq fixed subdomain with wildcard domains/tld

Tags:

dnsmasq

Is it possible to route all subdomain requests regardless of top level domain to a given ip with dnsmasq?

I would like to get something like this to work.

address=/dev.*/127.0.0.1

So any production url if prefixed with dev will route to my dev server. So any tld such as mysite.mobi or mysite.com if prefixed with dev. will still route to 127.0.0.1 So far I have tried the following with no luck

address=/dev./127.0.0.1
address=/dev*/127.0.0.1
address=/dev.#/127.0.0.1
address=/dev#/127.0.0.1
address=/#dev#/127.0.0.1

Any help would be great

like image 876
Darren Powers Avatar asked Nov 13 '22 03:11

Darren Powers


1 Answers

Not prefixed but postfixed, I've done the following on Xubuntu (on 14.04):

# install "dnsmasq"
sudo apt-get install dnsmasq

# create a configuration file for using .dev as tld
sudo nano /etc/dnsmasq.d/devtld.conf
# add "address=/dev/127.0.0.1" and save the changes

# restart the service after configuring
sudo /etc/init.d/dnsmasq restart

Ensuring that any URL ending in ".dev" is routed to 127.0.0.1 aka localhost.

For example, after above configuration the following are equivalent:

http://localhost:8080
http://127.0.0.1:8080
http://www.example.com.dev:8080
http://subdomain.example.com.dev:8080
like image 180
mdxs Avatar answered Jan 04 '23 02:01

mdxs