Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers 2

up vote 6 down vote accepted

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 192.168.0.3:

address=/.server.mydomain.com/192.168.0.3

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.

share|improve this answer
    
THAAAAAAAAAAAAAANKS –  Prody Mar 18 '10 at 17:12
    
Excellent! Had the same problem and the same solution worked fine for me, too! ;) Many Thanks. –  mnemosyn Apr 26 '10 at 13:16
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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