Advertisement

How To See A Router's Forwarding Table?

Started by August 09, 2016 03:03 PM
20 comments, last by Heelp 8 years, 3 months ago

Guys, as I already told you multiple times, I finished my primitive chat program using RakNet. It works perfectly fine, but only with laptops that are connected to my router, and it doesn't work when a friend who lives somewhere else tries to connect to me.

Then in the FAQ I see that it's because of NAT. From what I gather, IPv4 addresses are not so much, that's why some guys decided that instead of giving a different IP to every PC, they can just give a different IP to every modem and map the different ports of the modem to all the PCs connected to it.

And all the devices connected to that modem use the modem's IP, the difference is that everybody is connected to different port on the modem.

So my friend couldn't connect to me because when I googled "what's my ip", it actually shows my modem's IP, so I was giving him the public IP of my modem, not the IP of my PC. That's why I need to somehow access that NAT forwarding table on my router and figure out how to tell him the right destination. And I don't want NAT punchthrough, because I don't want to pay for server. I want to be the server. Is there some very simple way of doing this.

Can I somehow get a simple unique number from somewhere and shove it into my friend's Connect() function?

You need to set up port forwarding on your router, and how to do that should be in the manual for that hardware. Usually it involves finding the address in the manual, opening it up in your browser, entering the admin password, seeing which IP address it's assigned to you locally, then telling it to open an external port and forward that to your internal IP/port combination.
Advertisement

Sounds pretty complicated. Will try it, but I don't give myself any chances.

EDIT: I know my PC's internal IP address and my modem's external IP. Trying to figure out how to get my pc's external IP now.

Your PC does not have an external IP. That's the entire point of NAT. To everything not on your local network, your PC and your router are indistinguishable.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Guys, I found the options. I need to specify that packets coming to port 16000 (just random port I've chosen) of my router need to be sent to port 16000 of my PC. But in my router options, I have 2 slots for external ports, and 2 slots for internal ports, what to do?

EDIT: I will try writing the same port twice to fill the 2 slots, I hope I don't mess up something.

You look it up in the manual for the router. If you don't have the manual, Google.

If the web form has two numbers it is probably for a range. Many applications follow a range of ports such as 6881-6889 TCP. In that case you'd probably enter the first and last port in the range.

Advertisement

frob, you were right, it is indeed a range. I wrote a range of external ports from 59999 to 60001 and in the first slot for internal port I wrote 60000 and it automatically assigned 60002 to the second slot, so 2 external ports go to 2 internal. Now that I forwarded 2 ports, what do I write in RakNet's Connect() function?

peer->Connect(Should-I-Put-My-Router's-IP-Here?, Should-I-Put-External-Or-Internal-Port-Here?, 0,0);

EDIT: I still get CONNECTION_FAILED identifier. I'm tired of this sh*t. I stopped firewall, I forwarded external port 60000 to internal port 60000, I tried to connect to the router IP with the port number 60000 and it still doesn't work.

What are the two endpoints of the failing connection? NAT is usually set up to be one-way, ie. you don't connect to the public address and port if you're on the private side of the network.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

On the client, you should put the router's IP address, and the external port (being forwarded,) into the connect() function.
On the server, you do not use connect() at all.

So, let's assume your router's external address is 150.22.33.44, and that the external port is 5432.
Let's assume that your PC's internal address is 192.168.1.18, and that the internal port is 3800.

You should set up your router to port forward external port 5432 to internal address 192.168.1.18, port 3800.
You should then, in the client that connects to your router from the internet, put in the address 150.22.33.44 and the port 5432.

Now, if you try to connect to your PC from inside your network, your router may not support "hairpin NAT," and thus only when you are inside your network, you need to connect to 192.168.1.18 port 3800 for it to work.
enum Bool { True, False, FileNotFound };

Ok guys,

First: I want to thank you for the answers, There was no way I could understand all this stuff without your help, thanks.

Apoch: It just sends identifier 17, which is CONNECTION_FAILED, I tried with one of my friends, too, he is far away, he's not in my private network.

Second: I kind of get it, I need to use the router's external port and IP in the client's connect() function. And then somehow the packets enter that router through the external port and come to my PC from the internal port, cool.

But what port should I specify on the server side to listen on:

This is the code. I guess I have to specify the internal port here?( because we are talking about my pc here, and the external port is on the router, right )

RakNet::SocketDescriptor sd(InternalPortHere?,0);
peer->Startup(MAX_CLIENTS, &sd, 1);
peer->SetMaximumIncomingConnections(MAX_CLIENTS);
And another question. I specified the external and internal ports both as 60000, is there a problem if I use the same number?
Third question. There are some websites that check if a port is open, but I tried with 60000 and it shows that the port is closed although I forwarded it. This means that port forwarding doesn't open the port, just gives directions to the packet if it has already entered the port, right? ( or it just opens the external port? )
Question No.4: How the hell am I supposed to open my internal port. I guess it is in the peer->Startup() function?
Question No.5 How to open my router's external port?

This topic is closed to new replies.

Advertisement