Thomas’ Developer Blog

April 4, 2008

Setting up web server behind router (WRT54G2)

Setting up a server behind a router really isn’t that difficult, in theory, but in practice it can be a pain in the but.  It took me about 1 1/2 to get it up and running.  I’m going to go over the basics with you and share some of the biggest issues I had with setting up everything.

First off it’s important to note that I am using a WRT54G2 router.  I have a small apartment so I really didnt need much in the line of wireless, this setup was more just to configure the server correctly without using a cross over cable, which I will explain that method later on in another blog.

To begin make sure you have done the following:

- Have the router setup and working with internet connectivity.
- Have your server pre-configured to host your site. (If not search google, or view my next post for a brief)

Alright now that everything is working just fine by itself and you had the server working fine before you had the router setup, it’s time to go into some basic configuration.

First thing first is to go into the modem setup (you may have to do a direct connect to access this).  The IP may depend on your ISP.  In my case it was 192.168.1.254 for a DSL Westell modem.  If not go into CMD (command prompt) and type ipconfig to check your gateway IP, and type that into the browser.  Next, go into expert or advance setup and check to make sure you have no NAT settings in the way.

This is important since your router will control everything!  As far as IP Passthrough, you shouldn’t need to set it up to the server, but if you did before just leave it.  I left mine alone.  Once done go back and jot down your DNS information, both primary and secondary.

Next after making sure nothing is blocking your connection in the modem you can rig back up your network and make sure everything is working fine again, and you can connect to the internet.

Now in order to setup your server we need a static IP.  This is no big deal since you should already have a static IP on your ISP connection.  It’s basically the same theory, you need a static IP on your server (local machine on your network).  To do this some routers allow you to just go in and configure this.  In the WRT54G2 linksys router it doesnt work that way.  You have to just go ahead and manually configure it.  Which is actually a lot easier.

For more help on setting up the static IP for your router visit my other post:
http://sanzon.wordpress.com/2008/04/09/wrt54g2-static-ip-configuration-and-reconfiguring-router/

Now, simply go onto the server and go into your TCP/IP settings, if in XP under network connections, and properties for your connection.  If under Vista you’ll have to go into network sharing center, and click manage network connections and follow the same steps as XP.

(NOTE: If you already have a static IP Skip this step!!! Or write down all information shown before continuing!)

Now in properties you’re going to go ahead and manually configure your IP.  You’ll have to check with your router to figure out which IP to use.  In our case of the linksys router, we’ll use 192.168.0.99

You can use anything from 2-99 technically, you can even go higher, but for now just use 99.  0.1 is your router so that is already in use.  I use 99 to make it easier in case you add more devices to the network later that required static IPs.  If you are using a WRT54G you can set it to 192.168.1.11 since .0.99 will not work on a WRT54G.

For subnet mask type 255.255.255.0 which is almost always the case.

Default gateway should be your gateway for the router.  If you’re not sure just go into command prompt and check IP configure to get your gateway.  Same step as for the modem setup!

Now for your DNS you’ll use the DNS information you gathered from from your modem configuration.

After you type in those DNS addresses you can imply click OK.  At this point you should be able to connect just fine to the internet.  If not you can restart and see if you can connect again.  If nothing works, you’ll have to trouble shoot your modem/router connection.  Reference your router manual, or modem manual.  You may have to connect your router tech support or as I suggest use the online forum.  You can attempt to call your ISP, but trust me they won’t help! lol I used to work as a cable internet tech, I know this all to well. (Yes I’m well aware I’m using DSL now!)

Anyway assuming you have a connection setup and everything is fine working, now it’s time to move onto the fun part!

NAT and Port forwarding are methods used to send request from certain ports from the router to a local machine.  In our case the local machine is the server, and our port is 80 which is used for HTTP.  You may have to enable 8080 potentially, but try not to! (You’ll understand in a while)

Now before we configure NAT/Port Forwarding, we need to make sure that your router security doesn’t block anonymous connections.  Also make sure you don’t have remote access enabled!!!  ALWAYS HAVE THIS DISABLED FOR SECURITY REASONS!  If you are really wanting to do this then set it to port 8080!  This is why I told you to avoid using 8080 before, just in the case you really get annal or have blown a gasket and feel it’s a good idea to enable remote router access.  Ok you may have a legit reason, so if you do I appoligize, but you really should avoid using this if at all possible.

Now that I’m done stressing the importance of security, it’s time to move onto actually configuring NAT/Port forwarding.  In our case it’s called port forwarding.  Simply open Applications and Gaming under your router setup, and click port range forwarding.

Name the application HTTP1 or Web, or w/e you want.  It’s just for a reference.  Next enter 80 for to and from ports since we only want 80 to be allowed through.  I just used both for TCP and UDP connections, but you should really just use TCP is possible.  I’ll just say to use both to help trouble shoot.

For IP address, type in your static IP you setup on your server.  If you’re not sure just reverse the steps for using IP configure and find the local IP.  Now next is to simply enable it!  For NAT it’s the same steps, except there is only one port to choose.  Otherwise it’s pretty much the exact same.

After you enable it by clicking the checkbox click save, and your router should complete the setup.

At this point you should be good to go!

Go onto another computer on your network and try to access your domain or public IP, and see if you connect.  If not, try to connect using the machine’s local IP.

If you can connect then… skip this next paragraph.

If you can’t connect to a local IP, this was my lame issue.  You probably have a firewall.  So yes, while your firewall maybe disabled, also make sure you have proper access.  This shouldn’t be a problem if your server was already working before!  But I was setting up a new server in the process so I had some issues.

Ok, now to finalize your check I suggest going to the following site to check port 80 for access:

http://www.canyouseeme.org/

Just type in 80 and see if it works.  You can check all your ports technically.  Great little site!

Now after you check port 80 go to another site like:

http://www.google.com/language_tools

Now even though we don’t want to translate your page, you can atleast tell if someone from the outside world can access your site.  In the translation option choose english to japanese or w/e you want!  Leave as is to not translate it.

It should go through just fine!  If not, you have a server issue with IIS or w/e server management program you use.  Otherwise everything is working fine and you’re good to go!

In case you had some issues here are some ways to trouble shoot:

- remove ALL firewalls
- close any antivirus
- You can try enabling IP passthrough on the modem to the server at first then go back and try again with the router
- You can use IP passthrough to the router IP, this normally isn’t really useful, but if you have issues accessing your modem setup from behind the router, this trick will allow you to access it.
- Otherwise, check google/forums.  Worse comes to worse call up tech support for your router, then your ISP.  If all else fails just play around and in the process learn a lot of new stuff!  Or be the lazy business owner type and pay someone.

Anyway I hope this helps.  My next post will be for setting up a cross-over cable connection to configure two units on the same internet connection without a router!  And host your site at the same time!  Well good luck and happy coding!

  In our case we are using HTTP port 80.  Since you have already setup your server stand alone, there is no reason to check to make sure 80 isn’t blocked by your ISP.

In your NAT/Port forwarding section, port forwarding in the linksys WRT54G2

Now when going into NAT/Port forwarding on your router you will have to

7 Comments »

  1. Thank you for the info. I do want to add that if you try to point your browser to the internet IP address (address provided by ISP) within your firewall, it does not find the site. http://canyouseeme.org is a good resource. Otherwise, you’ll have to use an external connection to hit the web server for additional confirmation of your web server connectivity. I used my iPhone without my WiFi connection to do the test.

    Comment by Rich — August 15, 2008 @ 2:31 pm

  2. Hi, I´ve bougth a WRT54G2 router and I can´t make it work. I have a Toshiba Satellite Pro laptop with a built-in wireless card, which runs windows vista. It works perfect when wired to the modem.
    But every time i tried to install it the computer didn’t recognize it. Error 322 is launched and I don’t know what to do.
    Can you tell me where to begin?
    Thanks in advance

    Comment by Eufederico — August 20, 2008 @ 6:03 pm

  3. If your router is not working correctly, you can try installing the CD on another computer. I used my desktop to configure mine.

    You may need to download an update for vista if it’s having problems. Also with vista you can now right click on the steup.exe file on the CD and run in compatiabliity mode. Set it to XP service pack 2 and see if that works.

    I know some people sometimes have issues with linksys when connecting to DSL. You may need to go into your modem internal settings to configure it.

    Worse comes to worse try exchanging the router for another one at the place you bought it if you continue to have issues.

    Comment by sanzon — August 21, 2008 @ 6:38 am

  4. Hi,

    I am currently having problems with my linksys (WRT54G2) router. I am using bit commet torrent download and it said that my i should check my firewall NAT configuration. Where and how can I setup my linksys router(WRT54G2) so that I can do my usual downloads using bit commet?

    Thanks

    Comment by Paolo — August 31, 2008 @ 5:46 am

  5. If your torrent is not working due to a firewall, you can try going into your firewall settings and allow the port that bittorrent uses to bypass the firewall.

    If I get the chance I’ll go more into NAT configuration and other firewall settings on a later post, but that won’t be until sometime next week, asuming power is back up from the storm.

    Comment by sanzon — September 2, 2008 @ 4:02 pm

  6. Thank you very much Sir ,You simply rock

    Comment by hari — March 15, 2009 @ 10:41 am

  7. Hi

    I have got a static IP and router has been configured.

    Should I mention the static IP in the Server?

    when I access the static IP from IE, its asking user ID and password. and if given, its showing router page .

    1. How to access the website from the webserver

    I am using Windows server 2003.

    Thanks
    Pugal
    Chennai

    Comment by Pugal — November 18, 2009 @ 11:13 am


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.