Written by Topher Kessler
In order to start a screen sharing session with a computer behind a router, a simple port-forwarding setup that will route screen-sharing traffic to the desired computer on the network is a common suggestion. While this should be easy to set up for the most part, it is limited to only working with one computer unless you set up unique ports for each computer.
MacOSXHints has a recently published tip for connecting to multiple computers behind a router in this manner, which is a good example of how to use port forwarding to establish multiple connections to different computers that are running the same service. We will look into how to do this in more detail here.
The default port for screen sharing is the VNC port 5900, which can be opened in your firewall so traffic can get through and then be forwarded to a specific computer on the network. However, doing so will reserve screen sharing connections for the specified computer, so that whenever you connect to the IP address (router's IP address) with the following URL scheme for screen sharing, you will always connect to that one computer:
NOTE: This URL scheme can be entered into Safari's address bar, into the Finder's "connect to server" option (in the "Go" menu), and also directly into the "Screen Sharing" application by opening it directly (in /System/Library/CoreServices/).
To overcome this limitation and be able to specify which computer to which you would like to connect, you will need to set up port forwarding with unique conditions such as the following for each computer behind the router for which you would like to screen share (reference your router's manual for specific instructions):
External Port: 5900
Internal Port: 5900
External Port: 5901
Internal Port: 5900 (same for all computers)
In this manner, increase the number for the external port by one (ie, 5902, 5903, etc.) for each additional computer on the network with which you are trying to screen-share, ensuring each computer has a unique IP address. The external port number will be the port that you will connect to from a remote location, and the router will then forward it to the specified computer's IP address on port 5900 (the port that the computer's "Screen Sharing" service is accepting connections through).
Once you have the computers all entered in the router and have screen sharing enabled for each of them, if you just use "vnc://router_IP" as the URL to connect to, the system will default to port 5900 which will only connect to computer 1. Therefore you must specify which computer to connect to by specifying the port in the URL, as follows:
In our example, this port specification will be accepted by the router (which is accepting data on port 5901), and the router will forward it to the 192.168.1.3 IP address, but will use port 5900 (the internal port) when it does, which will allow "computer 2" to accept the Screen Sharing data.
With port forwarding set up like this, instead of specifying a computer on the network by IP address, you are specifying one by port number and allowing the router to know which IP address to send that port information. As such, all you need to know is your router's IP address, and which port number you specified for what computer.
While this tip is outlined for screen sharing, you can do this for pretty much any networking service, including AFP, SMB, and FTP file sharing services, game servers, and websites. This is a relatively old and simple way to connect to different computers on a network, but it works and is very useful.
Don't know the router's IP address?
The main problem with using port forwarding is knowing your IP address, which can be especially difficult with dynamic IP addresses. If your IP address suddenly changes because of an ISP network reset, or other situation such as loss of power to your router causes it to renew its IP from the ISP, you will be unable to connect until you can look up your router's IP address again.
There are many utilities out there that can detect the computer and router's IP addresses, and send out email notifications when the IP address has changed, and keeping one installed on a computer you always have running will ensure you're informed of your router's IP address. One such utility I recommend is Bwanadik, which is a simple menu item that supports email alerts.
Port forwarding setups are easy, but do require you to know IP addresses and enter port numbers in URLs. The easiest way to share with multiple computers is probably to subscribe to MobileMe, but many people may not wish to pay for this. If you are one of those people, and have access to your router's admin settings, then port forwarding setups such as this one may be the next best option.
Topher has been an avid Mac user for the past 10-15 years, and has been a contributing author to MacFixIt for just over a year now. One of his diehard passions has been troubleshooting Mac problems and making the best use of Macs and Apple hardware both for family and friends, as well as in the workplace. He and the newly formed MacFixIt team are hoping to bring enhanced and more personable content to our readers, and keep the MacFixIt community going here at CNET. If you have questions or comments for Topher or the other MacFixIt editors, feel free to contact us at http://www.macfixit.com/contactResources