Friday, February 5, 2010

How to access a home server behind a router/firewall

For users on a home network with a router installed, home servers are not accessible from the Internet because of many modern routers' built-in firewall.

Today we'll cover how to open up specific ports on your router to allow access to a home server behind a firewall.

Please note: this tutorial is for advanced users. Your router's firewall is there to protect you from evildoers who try to control your computer over the Internet. Make sure that any service you expose to the Internet is secured with a strong password.

Enabling outside access to an internal computer on a home network requires that you set up NAT - "network address translation," or port forwarding. Forwarding sends requests for ports on the outside of your firewall to the right computer on the inside.

For instance, someone on the outside requests a page from a web server at your router's IP address. With port forwarding set up, your router knows to forward requests for port 80 (a web server's default port) to the computer with the web server running only - and none of the others on your network.

Port forwarding is only necessary when you want to expose a service to computers on the Internet outside your firewall. Some servers you'd want to do that with:

  • a home web server
  • a personal wiki
  • a BitTorrent client uploading as well as downloading
  • a VNC server
  • a home FTP server

While all routers vary slightly, port forwarding is fairly simple. Here's how to get it set up:

Step 1. Determine your server's internal IP address.

All the computers on your internal network have an IP address which looks something like 192.168.0.XXX. Get on the computer with the server running and open a command window. Then type ipconfig to determine the machine's internal address, like so:

C:\Gina>ipconfig  Windows IP Configuration   Ethernet adapter Local Area Connection:          Connection-specific DNS Suffix  . :         IP Address. . . . . . . . . . . . : 192.168.0.11         Subnet Mask . . . . . . . . . . . : 255.255.255.0         Default Gateway . . . . . . . . . : 192.168.0.1 

In this case, as you can see, the server's internal IP address is 192.168.0.11.

Step 2. Configure your router.

Most routers have an web-based administrative interface that's located at http://192.168.0.1. (This address does depend on your model. Consult your router user guide for more info.)

Once you've gone to the router administration, entered the password (if one is set up), there should be an area called "Port forwarding." There, you'll set the port number that requests from the Internet will come in, and the internal computer that should fulfill those requests. Here's a screenshot of my Netgear router set up to port forward 5900 to my VNC server, which is at 192.168.0.11 (see above). Click on the image to see a larger version.

Here's a table of common services and their default port numbers.

ServicePort number
Web server80
VNC (remote control)5900
Instiki wiki2500
FTP21
BitTorrent6881-6990

No comments:

Post a Comment