Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I wrote a simple server application in C. I managed to establish a connection using telnet. The problem is that I cannot reach the server if I specify public instead of local ip in telnet. I mean this worked

telnet 192.168.1.2 20600

while this didn't

telnet 151.53.150.45 20600

I read around the web this is a NAT configuration problem, but port 20600 seems to be open (according to http://www.canyouseeme.org/ and http://www.yougetsignal.com/tools/open-ports/). Besides I disabled firewall, so it can't be the cause of the failure...

Any help?

share|improve this question

migrated from stackoverflow.com Apr 9 '11 at 6:50

This question came from our site for professional and enthusiast programmers.

    
What's your network topography like? Can you ping the box at 151.53.150.45? Is it the same machine as the one at 192.168.1.2? Are you using the same client for both requests? –  nmichaels Apr 5 '11 at 20:27
    
You didn't show any of your server's code. Are you binding to all the right interfaces when you listen? –  Lightness Races in Orbit Apr 5 '11 at 20:29
    
I have two notebook and a desktop connected to a router. No problem in pinging 151.53.150.45. Yes, 192.168.1.2 is the local ip. Yes, I'm using telnet for both. –  al fred Apr 5 '11 at 20:36
    
do you get connection refused? or does it simply wait and then fail? –  IanNorton Apr 5 '11 at 21:06
    
Connection refused –  al fred Apr 6 '11 at 7:13

3 Answers 3

A typical home NAT is designed to ensure that outbound connections can communicate with outside endpoints. By default, a home NAT does not forward ports on the external interface (e.g., from your cable modem provider) to your dev box.

You'll need to configure your NAT to forward inbound connections on port 20600 to 192.168.1.2. This is often called "port forwarding". Check out http://portforward.com/ for detailed guides for most hardware options.

Questions about that details of configuration would be more suitable for http://superuser.com.

share|improve this answer

Is your 192.168.1.2 machine behind a router? or is it THE router?.

You will usually need to setup a port forwarding rule to allow public traffic to port 20600 on your router to be redirected to 192.168.1.2

share|improve this answer
    
192.168.1.2 is behind the router. I already forwarded port 20600 to 192.168.1.2... –  al fred Apr 5 '11 at 20:56

I'll put on my psychic hat and guess at what's happening here.

You have a client, say 192.168.1.3, and you can connect just fine from it to 192.168.1.2. But when you try to connect from it to the external IP of your NAT router, you don't get anything. This is because you're on the inside of the NAT router and it is both cheap and not configured for this sort of thing. In order to verify that your server can be reached from outside your network, you have to try to reach it from outside your network.

Go to a friend's house and try to connect. If it doesn't work, make sure you've set up port forwarding properly on your NAT device. If it still doesn't work, ask a new question here and post some code.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.