• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Connecting to public IP addresses and port forwarding?

Status
Not open for further replies.
Level 15
Joined
Nov 30, 2007
Messages
1,202
I've made a game prototype using the client-server model but I can't seem to connect to a server on another network. LAN IP addresses work but public ones doesn't. Why is that?

Connection through LAN is established by entering the IP and server port.

Is it a port forwarding issue? Then the question becomes how does wc3 allow users to play online without opening a spot on the router for say 6112?

I'm no network guru as you might understand but would changing the server port to something standard, lets say HTTP (port 80), solve the problem?
 
Level 11
Joined
Jan 2, 2016
Messages
472
You would have to port forward on the machine which runs your server.It's all located in your router options.

On a side note i don't think it's a good idea running your server on ports like 80 or below for that matter.The reason for that is that there already are services that run on those ports.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
When you enter your local IP (e.g. 10.0.0.2, 168.192.1.2, or something similar), it just loops back to your computer, it doesn't actually register as an external connection to your router.
This is the same as using 127.0.0.1 (loopback) and localhost (same).

If you get your external IP, e.g. by searching "what is my ip" on Google, it's a different matter, since it now needs to go through the router's firewall, Windows firewall, etc.

A thing to note though, is that with some routers, even if a port is open, and you try to connect from your own computer, it will not connect, but anyone outside of your local network could access it.

As to Warcraft - almost no router in existence blocks outgoing connections, so you as a user have no issue connection to Battle.net, and to join games.
If you want to host games though, you do indeed need to open the ports, because that's incoming connections.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
The problem is likely due to NATs. Because all IPv4 addresses have been allocated, most computers connect to the internet through a NAT. NATs work well for out going connection, eg joining a WC3 game. They do not work for incoming connections, eg hosting a WC3 game. If you control the NAT you can create port forwarding rules to forward unsolicited incoming traffic to a specific local IP address. Some ISPs use carrier grade NATs due to not having enough IPv4 addresses for every client, in which case there is nothing you can do.

It works inside the local network because all computers are uniquely addressable. Like wise it should also work with an IPv6 internet connection because computers can then be uniquely addressed from outside the local network (no need for NATs in consumer networks).
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
if a person has a dynamic IP address, wouldn't that mean your allocation of there moderns IP address be useless?
IPv4 addresses are defined globally. ISPs were allocated blocks of the address range. They might or might not dynamically allocate them to their customers. This IPv4 address is the one used to communicate with the internet. They might also have to use a carrier grade NAT due to fewer IP addresses in their block than customers.

Since each customer only gets 1 IP address, if they are to connect more than 1 computer to the internet they need a NAT. Most "router" modems come with a NAT built in.

IPv6 should in theory fix this problem due to the much larger IP address spaces and blocks. However rollout is still only partial and most ISPs still do not give clients IPv6 addresses.

The reason clients are not allocated static addresses is that ISPs can commercialise that service for businesses.
 
Level 19
Joined
Jul 2, 2011
Messages
2,162
IPv4 addresses are defined globally. ISPs were allocated blocks of the address range. They might or might not dynamically allocate them to their customers. This IPv4 address is the one used to communicate with the internet. They might also have to use a carrier grade NAT due to fewer IP addresses in their block than customers.

Since each customer only gets 1 IP address, if they are to connect more than 1 computer to the internet they need a NAT. Most "router" modems come with a NAT built in.

IPv6 should in theory fix this problem due to the much larger IP address spaces and blocks. However rollout is still only partial and most ISPs still do not give clients IPv6 addresses.

The reason clients are not allocated static addresses is that ISPs can commercialise that service for businesses.
how would you gain the Nat or piv6 address?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
how would you gain the Nat or piv6 address?
Most local network bridges have NAT like functionality. Commonly they are found in "routers" such as those used for ADSL internet connections.

Obtaining a global IPv6 address is up to your ISP. For example BT in the UK is slowly starting to roll out IPv6 addresses to its customers, some have one but others like myself still only get an IPv4 address. Once you get one you will no longer have a public IPv4 address, if you had one that was not behind a carrier grade NAT already. IPv6 can still connect to IPv4 via a compatibility layer, often hosted by the ISP or a service the ISP subscribes to.

IPv6 solves a lot of problems with NAT since it has local network addressing built into the protocol, rather than allocating a dedicated range of addresses for the purpose that a NAT has to translate for. This means that with a single public IPv6 address one can have a huge local network and each machine will be uniquely identifiable in the public domain, as if it had a unique IPv4 address, so there is no point of having a local NAT any more. That said firewalls might become a big limiting factor to hosting on IPv6 as they can also be configured to block unsolicited incoming traffic, similar to what a NAT does automatically.

With a NAT one has to set up a port forwarding mapping. When one connects out through a NAT it automatically makes a temporary mapping for the return traffic so it can forward packets sent to your public IPv4 address to the appropriate local IPv4 address which is expecting it. The problem starts when one is trying to be connected to through a NAT as the NAT receives an incoming packet, has no mapping for such a packet, so is forced to discard it as it has no idea what to do with the packet. One can explicitly declare port forwardings on most NATs so that such incoming packets get explicitly forwarded to the specified local IPv4 address, hence allowing internet services running on the system at that address to be connected to. An obvious limit of this is that a packet can only be forwarded to a single local IP address, hence why games like Warcraft III that rely on local hosting allow the port number to be change as in order for multiple computers on the same network to host each requires a unique port forward mapping in the NAT, and hence a unique port number to receive communications from.
 
Status
Not open for further replies.
Top