6

I have a server application that I'm running two instances of, production and development, namely:

prod.example.com (10.0.0.1)
dev.example.com (10.0.0.2)

A third-party has written a client application which has been hardcoded to point to prod.example.com. But, I want those requests to go to the dev.example.com server and I don't have access to the third-party source code.

I do have access (temporarily) to the LAN that the client and server are running on so I can use dnsmasq to resolve prod.example.com to 10.0.0.2, at which point my work here is done and the client application will be (unknowingly) talking to the development server (or so I thought).

I've gotten as far as adding the following config to dnsmasq.conf..

address=/prod.example.com/10.0.0.2

..which does work, but it has the side-effect of preventing all other domains from resolving.

How can I have my cake and eat it?

Matt
  • 322
  • 1
  • 3
  • 11
  • 1
    Your side effect shouldn't happen. Nevertheless you can try editing `/etc/hosts`, or use `addn-hosts=` directive. – basin Aug 11 '16 at 17:20
  • What do you suggest putting into `/etc/hosts`? Mine has a bunch of mappings between `127.0.0.1` and my local development URLs – Matt Aug 12 '16 at 11:23
  • 1
    `10.0.0.2 `prod.example.com` – basin Aug 12 '16 at 12:04

1 Answers1

9

Add this line to /etc/dnsmasq.conf:

addn-hosts=/etc/dnsmasq.hosts

Then insert your domain names into /etc/dnsmasq.hosts:

10.0.0.1  prod.example.com.
10.0.0.2  dev.example.com.

Don't forget the period at the end of the domain name. It marks it as a TLD, not a local hostname.

As always after configuration changes, restart dnsmasq:

sudo service dnsmasq restart
FlippingBinary
  • 260
  • 2
  • 7