Jump to content
  • Advertisement
Sign in to follow this  
tmarques4

Port-forwarding implementation.

This topic is 2314 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

Greetings,

First of all, I'm using Ubuntu 12.04(precise) and I do sockets programming <sys/socket.h> on the C language.

I have developed a simple network program that comprises a server and a client, the client sends messages to the server and it prints the message on terminal, pretty straightforward. It works perfectly fine on a loopback interface or when communicating through computers on the same network, problem is connecting two computers on different networks. I believe rules should be added to the iptables so it allows proper communication, which can be done manually on the terminal but, preferably, one would want to just open the server program and have it send and receive packets without any type of iptables setup so, my question is, can port-forwarding be done on code?

Appreciate any help in advance!

Share this post


Link to post
Share on other sites
Advertisement
Not generally; there are workarounds known as "NAT punching" which might have some limited applicability, but it won't solve every case.


This would be a terrible security hole, for the record. Consider: I deploy a malicious program Foo and get you to run it on your Super Secure Network, probably via social engineering. Foo then commands the network to open ports to the outside world, and uses those ports to receive commands from FooController over the internet. Now I have complete control over your network and all I had to do was send BirthdayCard.exe to your secretary.

Share this post


Link to post
Share on other sites

Greetings,

First of all, I'm using Ubuntu 12.04(precise) and I do sockets programming <sys/socket.h> on the C language.

I have developed a simple network program that comprises a server and a client, the client sends messages to the server and it prints the message on terminal, pretty straightforward. It works perfectly fine on a loopback interface or when communicating through computers on the same network, problem is connecting two computers on different networks. I believe rules should be added to the iptables so it allows proper communication, which can be done manually on the terminal but, preferably, one would want to just open the server program and have it send and receive packets without any type of iptables setup so, my question is, can port-forwarding be done on code?

Appreciate any help in advance!


if the machine running your server application is the one doing the routing then you shouldn't have to do anything as portforwarding is only necessary if you want to map a port on the router to another machine on the same network.

If the machine running your server is behind a router then you have to configure port forwarding on the router. (doing things with iptables won't help there).

Share this post


Link to post
Share on other sites
It appears punch-through shall suit well for my needs. I did a small research and look forward to implement it and get rid of this nagging issue.

Thank you all for the help!

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!