Jump to content
  • Advertisement
Sign in to follow this  
Heelp

How To See A Router's Forwarding Table?

This topic is 859 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Edited by codeBoggs

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites

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.

Edited by codeBoggs

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Edited by codeBoggs

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Edited by codeBoggs

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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?
Edited by codeBoggs

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!