Configuring Port Forwarding with UPnP under Windows XP

Articles on how to do things in MapTool (answers only here -- questions should stay in the main MT forum)

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Forum rules
Please discuss all HOWTO topics in the main forum. They will be moved here by a moderator when appropriate.
Phergus
Deity
Posts: 7132
Joined: Fri May 12, 2006 8:56 pm
Location: Middle of Nowhere, NM
Contact:

Configuring Port Forwarding with UPnP under Windows XP

Post by Phergus »

All that follows is a discussion of using UPnP from Windows OS itself to configure your router. None of this is needed to use the UPnP option in MapTool's Start a Server dialog. If your router supports UPnP, simply enable it on the router and then use the UPnP option in MapTool. No other action is required

It is actually possible to configure port forwarding on most popular broadband routers via Universal Plug-n-Play (UPnP) from your Windows XP PC. Unfortunately, it appears that a couple components needed to do this are not part of the default Windows XP installation but are easily added.

Either use the UPnP feature of your router to dynamically configure your port forwarding or go into the control panel of your router to create a static entry. Don't try to do both.

Preparation
  • First make sure your broadband router supports UPnP and that it is turned on. Check your routers documentation for information on how to do this. For LinkSys routers it is normally found under Administration/Management.
  • Find your Windows XP CDROM if you have one. Many pre-built systems will have everything you need already on your disk but not installed yet. On these you may not need the OS disc.
Installing UPnP Components
Open your Network Connections window from the Start Menu via Start/Settings/Network Connections. You should see something like this:

Image

If you already have an item that says Internet Connection - Internet Gateway, you can probably skip to the next section on Enabling Port Forwarding.

If you don't see an Internet Gateway type entry, then the rest of this applies to you.

Select Optional Networking Components from the Advanced Menu. You should see a dialog like this:

Image

The middle item, Networking Services, is the one you are interested in. Select it and then click on the Details button. You should see a dialog like this:

Image

There are two items that need to be installed if they are not already checked.
  • Internet Gateway Device Discovery and Control Client
  • UPnP User Interface
Check these two items and then click OK to return to the previous dialog.

Click on Next and the new components will be installed. Depending on how the OS was installed you may be prompted for your Windows XP CDROM.

Once installation is complete you should see an Internet Connection item in the Network Connections dialog. If you don't, try selecting Refresh from the View menu or closing and reopening the dialog. If you still don't see it, review the previous steps and make sure all the steps were followed. Also make sure the UPnP is enabled for your broadband router. Consult your user guide for details on how to do this.

Enabling Port Forwarding
Once you have the Internet Connection item of type Internet Gateway in the Network Connections dialog, select it and then select Properties from the File menu. You should see a dialog like this:

Image

Click on the Settings button to open the Advanced Settings dialog. You should see a dialog like this:

Image

In all likelihood there will be no Services listed. Any that are listed and have the check mark indicate that you have some software running that has an open port to the internet. Make sure this is something you want.

To get MapTool up and serving to your players on the internet, click the add button to open the Service Settings dialog. You should see a dialog like this:

Image Image

Your dialog should have all the fields empty. Enter a Description. MapTool might be a good choice for this.

Put in your internal IP address. You can get this from the Server Info (aka Connection Information) dialog in MapTool shown next to the Service Settings dialog above.

Remember! You want the local address and not the external address.

Next put in the External & Internal Port numbers. The default for MapTool is 51234. Use the default unless you have some reason to use another number and know what numbers are okay to use.

Ensure that TCP is checked and then click on the OK button.

The Advanced Settings dialog should now look like this:

Image

If it worked you get an entry for MapTool (or whatever you chose).

If you get an error when doing this, check that UPnP is enabled on the router and that you used the correct IP address.

That's it. Start MapTool and do a Test Connection from the Start Server dialog. It should report success.
Last edited by Phergus on Sat Feb 07, 2009 11:59 am, edited 1 time in total.

Phergus
Deity
Posts: 7132
Joined: Fri May 12, 2006 8:56 pm
Location: Middle of Nowhere, NM
Contact:

Post by Phergus »

Or for those that might want to automate things with a couple Visual Basic scripts you can employ these:

Script to enable Port Forwarding

Code: Select all

' Save as mtenable.vbs or whatever you prefer
' This script enables the MapTool server port.
' Based on info from http://www.knoxscape.com/Upnp/NAT.htm
'
' This script gets your IP address dynamically but may 
' not work as expected if you have more than one network
' adapter.
'
Set theNatter = CreateObject( "HNetCfg.NATUPnP")
Dim mappingPorts
Set mappingPorts = theNatter.StaticPortMappingCollection
' Get the IP address
Dim ipAddress
set IPConfigSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
("select IPAddress from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
for each IPConfig in IPConfigSet
  if Not IsNull(IPConfig.IPAddress) then
    for i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
      ipAddress = IPConfig.IPAddress(i)
    next
  end if
next
'MsgBox("IP Address: " & ipAddress)
'Add the default MapTool port of 51234 for the IP address found
mappingPorts.Add 51234, "TCP", 51234, ipAddress, TRUE, "MapTool"
Script to disable Port Forwarding

Code: Select all

'Save as mtenable.vbs or whatever you prefer
'This script disables the MapTool server port.
'Based on info from http://www.knoxscape.com/Upnp/NAT.htm
'
Set theNatter = CreateObject( "HNetCfg.NATUPnP")
Dim mappingPorts
Set mappingPorts = theNatter.StaticPortMappingCollection
'To uniquely specify a forward, you give the external port
'and the protocol - here we remove the forward that we added
mappingPorts.Remove 51234, "TCP"
As described in the previous post, your router must already have UPnP enabled for these to work.
Last edited by Phergus on Sun Feb 10, 2008 10:42 am, edited 1 time in total.

Phergus
Deity
Posts: 7132
Joined: Fri May 12, 2006 8:56 pm
Location: Middle of Nowhere, NM
Contact:

Post by Phergus »

Last but not least, here is a really cool tool for playing with UPnP and Port Forwarding:

http://www.codeproject.com/internet/PortForward.asp

You'll have to create a login on CodeProject to download it.

User avatar
WhisperedThunder
Kobold
Posts: 13
Joined: Fri Feb 01, 2008 11:07 pm

Going a little crazy

Post by WhisperedThunder »

Hello. I've enabled UPnP on my router, but after I install the two required networking components under Networking Services I still don't get an Internet Gateway connection (after refreshing/restarting/etc). I'm finding this especially frustrating because I've just installed a fresh copy of XP Professional. If you have any idea what's going on, I'd really appreciate some advice. Also, I don't know if this matters, but the Hamachi workaround isn't working.

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

UPnP on Windows

Post by Azhrei »

(I don't have anything useful to add, but I wanted to be able to search for all of my posts and find this thread. I plan to add this to my new Networking FAQ, since it has nothing about this topic.)

Phergus
Deity
Posts: 7132
Joined: Fri May 12, 2006 8:56 pm
Location: Middle of Nowhere, NM
Contact:

Post by Phergus »

What router?

Did you try the VB scripts I posted above to make sure your router can be seen/controlled from your PC?

Do you have another PC on the network to try it with?

That you didn't get Hamachi working suggests there are other networking/OS issues.

User avatar
WhisperedThunder
Kobold
Posts: 13
Joined: Fri Feb 01, 2008 11:07 pm

Post by WhisperedThunder »

It's a WRT300N LinkSys. And I tried MapTool on a Vista machine on the same network earlier this week with the same results.

I don't mean to sound like an idiot, but how do I run VB script?

Are there any screencaps I could take of the router settings that would be helpful?

Phergus
Deity
Posts: 7132
Joined: Fri May 12, 2006 8:56 pm
Location: Middle of Nowhere, NM
Contact:

Post by Phergus »

Open Notepad (Start/Run/Notepad) and copy/paste the contents of the code blocks above into Notepad. Do the first block and save it as mtenable.vbs to C:\temp or some other easy place to get to. Copy paste the second block into Notepad and save as mtdisable.vbs.

Then open a DOS window. (Start/Run/cmd)

Type in "cd c:\temp" or wherever it was that you saved the two script files.

Then just type the name of the first script: mtenable.vs

It should run and you'll get error messages if it doesn't.

If it succeeds then run the second script to close the port again.

If your router has UPnP enabled and is visible from your PC this should work.

User avatar
WhisperedThunder
Kobold
Posts: 13
Joined: Fri Feb 01, 2008 11:07 pm

Post by WhisperedThunder »

mtenable produced the following error:

Image

Phergus
Deity
Posts: 7132
Joined: Fri May 12, 2006 8:56 pm
Location: Middle of Nowhere, NM
Contact:

Post by Phergus »

Apparently you're missing a Visual Basic runtime library.

I believe you can get what you're missing here:

http://support.microsoft.com/kb/290887

User avatar
WhisperedThunder
Kobold
Posts: 13
Joined: Fri Feb 01, 2008 11:07 pm

Post by WhisperedThunder »

I downloaded and ran VBRun60sp6.exe, but I'm getting the same error when I run mtenable

Phergus
Deity
Posts: 7132
Joined: Fri May 12, 2006 8:56 pm
Location: Middle of Nowhere, NM
Contact:

Post by Phergus »

Then you'll need to double-check that the copy-paste worked correctly.

Open up the mtenable.vbs file in Notepad. Check it against the code in the first Code Block above. Check for the closing quote marks on the last line and make sure to hit enter at the end so that the file ends on a single blank line.

The error occurred on the last line of the script so that is the likely place to check.

User avatar
WhisperedThunder
Kobold
Posts: 13
Joined: Fri Feb 01, 2008 11:07 pm

Post by WhisperedThunder »

The paste was correct, but I didn't have the blank line at the end. So now that's done and I have a different message. After I run the script I still can't connect with MapTool, but an Internet Gateway connection appear in my Network Connections. But it's disabled and when I try to enable it I get this:

Windows Script Host

Script: C:\mtenable.vbs
Line: 25
Char: 1
Error: 0x80040211
Code: 80040211
Source: (null)



Or at least I think that's the case. That might be an error from the script that pops up later for some reason and just happens to coincide with when I'm trying to enable the gateway.


After days of trying to make this work my system is currently set so that the router is DHCP-enabled, but this computer is using a static IP. UPnP is enabled and no Port Forwarding is currently set up.


Update: After pounding my head into a table for hours I finally went and just started Google-ing everything related to my router and port forwarding. It seems that my Comcast-provided Arris modem doesn't play well with others: http://www.dslreports.com/forum/r199571 ... ksys-issue

I'm having a terrible time with this, but given that I have an Arris modem it seems likely that the problem lies there and not with MapTool or any of your Port Forwarding instructions (or VB script).

Phergus
Deity
Posts: 7132
Joined: Fri May 12, 2006 8:56 pm
Location: Middle of Nowhere, NM
Contact:

Post by Phergus »

WhisperedThunder wrote:After I run the script I still can't connect with MapTool,
So does the script run completely and return you to the prompt?
WhisperedThunder wrote:...but an Internet Gateway connection appear in my Network Connections. But it's disabled and when I try to enable it I get this:
When you say "try to enable" do you mean you right-click on the connection in Network Connections and select Enable?
WhisperedThunder wrote:Windows Script Host

Script: C:\mtenable.vbs
Line: 25
Char: 1
Error: 0x80040211
Code: 80040211
Source: (null)

Or at least I think that's the case. That might be an error from the script that pops up later for some reason and just happens to coincide with when I'm trying to enable the gateway.
That's pretty weird. Once the script finishes there shouldn't be anything left running.
WhisperedThunder wrote:After days of trying to make this work my system is currently set so that the router is DHCP-enabled, but this computer is using a static IP. UPnP is enabled and no Port Forwarding is currently set up.
You know you don't have to use UPnP if you are comfortable going into your router controls and opening a port.
WhisperedThunder wrote:I'm having a terrible time with this, but given that I have an Arris modem it seems likely that the problem lies there and not with MapTool or any of your Port Forwarding instructions (or VB script).
Well you could always get your own cable-modem from the local Best Buy or whoever instead of paying rent to Comcast for one.

User avatar
WhisperedThunder
Kobold
Posts: 13
Joined: Fri Feb 01, 2008 11:07 pm

Post by WhisperedThunder »

Phergus wrote: So does the script run completely and return you to the prompt?
To be honest, that time I didn't run it through the command prompt, and now trying to run it gives me that same old object error.
Phergus wrote: When you say "try to enable" do you mean you right-click on the connection in Network Connections and select Enable?
Yep
Phergus wrote: Well you could always get your own cable-modem from the local Best Buy or whoever instead of paying rent to Comcast for one.
It's really looking like that is the only option left to me. I read that what I might need to do is go into the Modem and tell it to forward the appropriate ports on to the router, but I contacted Comcast and they basically told me I couldn't do that and they weren't going to help. It's a modem that control my phone line and tv though, so I worry about changing it from Comcast's standard.

I'm not very familiar with all these things, but from what I understand the modem denying things to the router sounds like one of the few things that would stop Hamachi from working. I'm grumpy with Comcast and these Arris people. I want to play some D&D.


Update: I'm still mad at this Arris router, but I've figured out how to make Hamachi work. So now...gaming! Thanks again for all your help.
Last edited by WhisperedThunder on Sun Feb 10, 2008 9:16 pm, edited 1 time in total.

Locked

Return to “How To”