Darren Powers
Darren Powers

Reputation: 77

dnsmasq fixed subdomain with wildcard domains/tld

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

Upvotes: 5

Views: 2657

Answers (1)

mdxs
mdxs

Reputation: 147

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

Upvotes: 1

Related Questions