Network’s DNS queries redirection to localhost

dnsNetwork

Before saying anything, I would like you to know that my experience in the field of network administration is about 3 days long, so please treat me like the newbie I am. I have also been looking around 2 of these 3 days trying to find the best way to achieve my objective, and I have found similar questions around the internet, but I have not been able to do it.

I am running an Apache2 server on localhost:8080 from a Mac OS X fully updated Lion. This Mac is connected through Ethernet (interface en0) to a wireless Access Point. In the AP, I have set up the gateway to be 192.192.192.1, and I have given that IP address to en0. The objective of this network is redirecting anyone's http/https petitions to the localhost of the gateway, showing them the page that apache is serving.

If before this point there's any conceptual mistake, please let me know

As far as I have understood, the best way to do this redirection is using the pf.conf file and pfctl, but the man page of pf.conf left me with a bit of a WTF face. I have found in freebsdonline.com these instructions to do something similar:

# --------- pf.conf ----------
int_if="fxp0"
ext_if="fxp1"

rdr on $int_if inet proto tcp from any to any port www -> 127.0.0.1 port 8080
pass in on $int_if inet proto tcp from any to 127.0.0.1 port 8080 keep state
pass out on $ext_if inet proto tcp from any to any port www keep state
# ------- end pf.conf -------

The thing is that this pf.conf seems to be forwarding packets between 2 interfaces, and I dont need that (do I?). Could you help me to adapt, or at least understand that lines? And is there anything else I need to do once that lines have been added to pf.conf?

P.S: If you know any easier way of doing this redirection stuff, I'll be glad to hear it. I though about using dnsspoof, but I haven't been able to find it for OSX.

Best Answer

Since you didn't mention it, I would make sure to navigate to:

/private/etc/apache2/  

and open (using your text editor of choice; vi/m works, of course)

httpd.conf  

Once you're there, make sure that lines 39 and 40 (or thereabouts) read:

Listen *your_web_site's_address*:8080  
Listen 8080  

If it reads

Listen 12.34.56.78:80  
Listen 80  

Then that is certainly a big part of your problem, as the server is listening on the wrong port altogether. As always, make sure to properly configure your firewall(s)!