Click to See Complete Forum and Search --> : running Apache on a router


HiGh
03-14-2003, 03:12 PM
Well, I've been looking around EVERYWHERE for a solution to this, and I can't find anything that helps. I am on a Belkin 4-Port Cable/DSL Gateway Router, Windows XP Home Edition, and I'm trying to run Apache. For one thing, I'm not sure what to put in as my servername in httpd.conf, should I use my WAN IP or the DNS IP that my router gives me? Can I even run a server with what I have? I've been considering just ditching the router and buying a hub, but I can't afford any at the moment, and I want to get a server running BAD....

So, in short:
I have a Belkin 4-Port Cable/DSL Gateway Router
Running Windows XP Home Edition
And when I install Apache I'm unsure what to put as my servername, etc., because when I go on my router's configuration settings it gives me a WAN IP, subnet mask, gateway IP, and two DNS IP's.....

Can I even run a webserver with what I have?

Rune
03-15-2003, 12:32 PM
Originally posted by HiGh
Can I even run a webserver with what I have?

Absolutely! :)

One of the first things I'd advise: it sounds like you're probably running DHCP, ie your router picks the IP to assign to each computer on your LAN. I'd change that and turn DHCP off and assign IP's to each PC. The reason being is that otherwise your PC's can change IP's (usually only when restarted) and can screw up which computer your router sends HTML requests to.

Second step, (I have a Linksys router so the place where these settings are may be different, but ...) go into your router settings and turn on forwarding for the HTML/port 80 requests. On mine it's Advanced Tab > Forwarding > UPnP Forwarding. Like I said, it's probably different on yours but one way or another you need to find where the HTTP port 80 is being forwarded to and make sure that's enabled and set to the IP address of the PC that's running the Apache server.

See, your router actually has two IP addresses - one is the WAN IP that your ISP assigns to you - your ISP will see your router as the "one and only computer" they're attatched to at your place - they won't see the dozen pc's on the other side of your router. ;) The other is your LAN IP which is usually 192.168.1.1 by default - which only the computers in your LAN will see. Your PC's should be assigned similar IP's and I'd reccommend 192.168.1.x for clarity (for example, my PC's are 192.168.1.11, 192.168.1.22, 192.168.1.33, etc - just remember not to use 0, 1 or 255 for the last set of numbers).

This way, your LAN will see things as:
Router = 192.168.1.1, subnet mask: 255.255.255.0
PC1 = 192.168.1.11, subnet mask: 255.255.255.0
PC2 = 192.168.1.22, subnet mask: 255.255.255.0
PC3 = 192.168.1.33, subnet mask: 255.255.255.0

Your ISP (and WAN) will see things as:
HiGh's House = 4.46.87.94, subnet mask: 255.255.240.0
(or whatever IP, subnet settings they gave you - if you have a dynamic IP, leave these WAN settings as "Obtain Automatically" ... and just assign the LAN IP's and subnet masks).

And as long as your router's settings are set to send any HTML/port 80 requests to the PC where Apache is running (ie 192.168.1.11 if it's on PC1) ... you'll be cool. :)

Now as far as the server name, if you have registered for a domain name (ie www.mydomain.com) use that as the server name. If you don't have a domain name, use your EXTERNAL IP address, aka "WAN IP".

Good luck! :)

willuff
03-19-2003, 02:33 AM
The only other problem you may well experience is that if your router gets its ip address from dhcp, it is difficult to get your domain name to resolve to an ip that could change every few days (or few hours in my case!).

What i do is use http://www.zoneedit.com/ which is free (up to 5 domains) and use their dynamic dns.

What this means is that every time my router (in my case my linux pc) gets assigned a new ipaddress, i inform them of the change (in my case automatically but if you're using a real router then it might not be so easy), and 20 mins later they have updated my DNS. Given the usual 24 hour wait, 20 mins is not that bad.

But as per the above response, that'll work perfectly if you know the ip address that you're router is assigned at the time you go to make the apache request.

To be honest, you need a static ip to make it seamless but if its not mission critical then dynamic dns can be well handy.

Rune
03-19-2003, 09:31 AM
For the WAN IP - agreed. A Static IP from your ISP is ideal, but if your router, electricity service and ISP service are reliable enough and left on 24-7 ... dynamic is just as good ... and often half the cost. ;)

ie The only time my dynamic IP changes is when Verizon DSL goes out for several hours (as usual) ... or our electricity goes out for several hours.