data-ad-format="horizontal">

Using Windows VNC On Standard TCP/IP Ports

VNC LogoThe VNC (Virtual Network Computing) application is quite a popular program for use as a remote control application. The program is free, and Open Source and can be used in a wide variety of situations. While you can now control port numbers easily in the interface – you may want to know how port numbers are changed on a Windows system. In this article I will describe how to setup the VNC Server (On Windows) to use ports that are commonly used on the Internet.

One typical reason you would want the VNC server you run in your home on a different port is that you may not be able to the default ports VNC uses when installed. The VNC server uses port 5900 by default and if you decide to change something called a “Display Number – More on this later” the port number changes to 5900 plus whatever number you typed as the display number.

Background

First, a little background. The VNC application consists of two pieces the first being the “server” that serves the desktop of a computer and a “viewer” that allows you to connect to a desktop of a computer. The nice thing about VNC is that you can use it on many platforms, UNIX, Linux, Windows and all sorts of other platforms as viewers. Given the differences in these platforms, VNC’s use becomes confusing because the terminology VNC uses does not change across versions.

On the Unix/Linux platform VNC runs and serves out desktops that are in addition to the one run at the console. These desktops are called displays when you read this in the VNC documentation. With your UNIX/Linux version you also have the option of specifying a port number by way of the “-rfbport” options when running the Xvnc server. The default port is 5900 plus whatever display number you use when you start the server. In the case of UNIX/Linux VNC is used allot like Citrix Metaframe in the Windows world.

Now we get to Windows where things change. VNC cannot do what Citrix does on Windows mainly because of the Operating System limitations. VNC on Windows then, is only used to serve out the desktop/console of a Windows computer. On Windows there are two components – the server “winvnc.exe” and the client “vncviewer.exe”. if you run the server, then run the client and connect to the server’s IP address, you get a connection. This connection, by default is on port 5900.

Dealing with ports

You should know that older versions of VNC did not let you change the port at all. You would have had to change, and recompile the source code provided to have a new port number. In recent versions (this article is based on 3.3.7) the port number can be controlled, but must also deal with Display Numbers and a number of other confusing settings to make it all work..
To change the port number of your VNC Server you must first install VNC (goes without saying) and once installed, edit the registry location where the VNC ports settings exist. You find the port settings in this key:

HKEY_CURRENT_USER\Software\ORL\WinVNC3

You first want to set the value for “AutoPortSelect” to 0 (it defaults to 1). This will stop the VNC server from automatically setting the port number. The second thing you want to do is create a “DWORD” entry in the same key called “PortNumber” if it does not already exist. Once created set this number to the Decimal (not Hex) number of the port you would like to use. In this article I will use examples of three well-known ports 21 (FTP), 23 (Telnet), and 80 (Web). If you have set the “PortNumber” value to the Telnet port you will see (on the same line in regedit):

PortNumber………….REG_DWORD………..0x00000017(23)

Now run your VNC Server and set other options that might be in the configuration dialog box.

What’s with the configuration window?

Funny you should ask, if you set the port number to 21, the VNC Server configuration dialog says the display number is “4294961417”, if you set the port number to 23, “4294961419” and finally port 80, “4294961476”. if you look closer, you will see a pattern, but in the interest of time leave the number the way it is. You might be asking a question, If I put the above numbers into the configuration window, will the corresponding port number be used? The answer is no – at least not on the version I have tested. It appears as though the VNC server configuration was not built to handle number like this. So, now that the port is the way you would like, lets look at connecting to the server.

Connecting with the VNC Client

So, by now you see how this who “Display Number” setting is starting to make things confusing. You might be asking yourself “why didn’t they just give us a port number option?”. Good question, because it gets worse. When you connect to the VNC server you use the VNC client application. This application opens up a window that gives you one area to type in text that corresponds to the server you would like to connect to. The structure of this connection is as follows:

ipaddress or host:[display number]

The IP address or host is required and is the IP address or hostname of the computer running the VNC Server and the display number is optional defaulting to 0 if you put nothing. If you just put the IP address of our server running on the special port, you’ll find that it won’t work – because its looking for port 5900 by default. The trick is to use the display number.
You can use the display number in two ways, both of them make no sense – but hey! This program is free. You can use the corresponding huge numbers to connect like this (IP is an example only):

Port 21
200.200.200.200:4294961417

Port 23
200.200.200.200:4294961419

Port 80
200.200.200.200:4294961476

But! there is a lesser-known way to do that that might be a bit easier to remember. You just take the port your connection to, and then subtract 5900 from that number. Your left with a negative number in the -5877 format that can be used to connect. So, I’ll do the above with these numbers:

Port 21
200.200.200.200:-5879

Port 23
200.200.200.200:-5877

Port 80
200.200.200.200:-5820

There you have it! Now you know how to setup your VNC server on port 21,23, or 80 and how to use the client to connect to your home. If you have any other ports you would like to use or more information on how how VNC works let me know.

As always, you can get VNC here.