I have a network behind a NAT with a few machines.

The machines are:

  • router - NAT, dnsmasq, forwarding - directly connected to the inet
  • server - which runs ssh, www and some other stuff
  • clients - which do stuff on server

I also have mydomain.com.
server.mydomain.com is pointing to my connection's IP (single IP), which is the router, which forwards ports to server.

Server, has a httpd running, which serves different sites based on vhosts.
So I have site1.server.mydomain.com, site2..

The problem is that all the traffic is going thru the router, and when I check logs I always see the router's IP for everything (so it's hard to see who is running the script with the while(1)).

I would just ServerAlias site1.server.local, but most of the sites have a root URL saved somewhere on top of which other URLs are built, so I can't do that.

The solution for me would be telling dnsmasq somehow to answer to *.mydomain.com with server's IP.

Is this possible somehow?

2 Answers 2


I do the exact same thing on my dev server(s) so that I can have an rsynced mirror locally and on the off-site server with identical configs.

Here's what you need in your dnsmasq.conf (make sure you restart it) assuming your webserver's internal interface is


This will create a wildcard entry for *.server.mydomain.com and as long as your client's are using DNSMasq for their DNS (and your server listens in the internal interface), you're set.

    – Prody
    Mar 18, 2010 at 17:12
  • Excellent! Had the same problem and the same solution worked fine for me, too! ;) Many Thanks.
    – mnemosyn
    Apr 26, 2010 at 13:16

I'm not sure that I understand your issue but it seems to me that the root cause of your troubles is NATing incoming connections on your router. More specifically, since you said that all incoming connections appear in the logs with the router ip address, it seems like you're masquerading all incoming connections.

What you should do is DNAT incoming connection and SNAT outgoing connections on the router which would preserve the source ip of each connection.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.