Settings
Router huawei HG532b configured to forward port = 50111 by enable NAT > DMZ and put
Host address IP = 192.168.1.5 , and that is static IP of my PC in the Network.
the router configured to forward port = 50111 by mapping the port by NAT > Port Mapping with following settings:
Protocol = TCP/UDP, External port = 50111, Internal port = 50111,
Internal host = 192.168.1.5, Remote host = 192.168.1.5, Mapping
name=Chat.
the router configured to forward port = 50111 by triggering the port by NAT > Port Triggering with following settings:
Trigger protocol = TCP/UDP, Trigger start port = 50111, Trigger end
port = 50111, Open start port = 50111, Open end port = 50111, Trigger
name=Chat
The router have public or external or WAN IP = 188.167.2.4.
The router configured to enable UPnP.
The router configured LAN > DHCP by make Start IP address = 192.168.1.6, End
IP address = 192.168.1.253
The router is my Gateway with IP = 192.168.1.1.
My PC have static IP = 192.168.1.5, and the firewall service is off, and there is no antivirus installed or any other firewall, and I have XP with service pack 3.
Problem:
I Created two programs, Client and Server, they are parts of the chat program.
Server's socket have LocalPort = 50111 and put to Listen mode.
Client's socket have RemotePort = 50111, and have text box to put the remote IP in it and Command button called Connect.
When I test the Client and Server in the same PC that have Static IP = 192.168.1.5 and put the remote IP in Client = 192.168.1.5, everything go fine.
When I test the Server in the PC that have Static IP = 192.168.1.5 and put Client in PC with IP = 192.168.1.9 and put the remote IP in Client = 192.168.1.5, everything go fine.
When I test the Client and Sever in the same PC that have Static IP = 192.168.1.5 and put the remote IP in Client = 188.167.2.4 (that is my router public or external or WAN IP), and press Connect, the winsock error "connection is forcefully rejected" is raised.
When I test the Server in the PC that have Static IP = 192.168.1.5 and put Client in PC with IP = 192.168.1.9 and put the remote IP in Client = 188.167.2.4 (that is my router public or external or WAN IP), and press Connect, the winsock error "connection is forcefully rejected" is raised.
When I test the Server in the PC that have Static IP = 192.168.1.5 and put Client in PC in another network with IP = 192.168.1.7 and put the remote IP in Client = 188.167.2.4 (that is my router public or external or WAN IP), and press Connect, the winsock error timout is raised.
I read that if the Client and Server in the same PC, setting the Client remote IP to public or external or WAN IP will not work.
I read that the XP with service pack 3 have issue with port forwarding.
I read that there is a technique called hole punching, that can round over router port forwarding or firewall.
I want an expert to explain to me, what is wrong and how to correct it.
From looking at your tests you are experiencing problems from with out side your own private network. There are two possibilties that could be giving you problems and its more likely to be your port forwarding thats causing the issue
1: Port forwarding && DMZDMZ is something you don't want in this case as thats another layer of security on top of the security thats all ready active on your router and will give you those rufused connections. Look at the following page on how to set up port forarding
http://portforward.com/english/routers/port_forwarding/Huawei/HG532b/Xbox_Live_360.htm
Setup the one rule with the following information
External port: 50111
Internal port: 50111
Internal host: 192.168.1.5
Protocol: This can be set to TCP/UDP, if you are using both in your application then thats fine but if you are using just the one then best to set this to the one your are using.
2: External IPFrom time to time your router will drop connection from the internet and re-connect and on occasions your external ip address can change, check with https://www.whatismyip.com/ to see if the ip address has changed. If you are looking for the bigger picture with your application then may be worth looking into getting dynamic address, have a look at this for more information http://www.noip.com/support/knowledgebase/what-is-a-dynamic-ip-address/
Hopefully this helps you
Related
So... if i want my tcp server can be connected by other network(not just local network), i will need to setup port forwarding in my router setting page. But it's so annoying so i'm wondering is there other way to port forwarding from public IP to my local IP address.. maybe with code?
When I launch a server in my pc he is listening any ip and a port 105. If a client on another computer wants connect to the server in my computer he is using local ip address like 192.168.1.101.
If a client will use my local ip address (192.168.1.101:105) to send a request, then my server will be able to receive it?
So long as there is a network route between the two computers and no firewall getting in the way: yes.
When we ping to any Public IP of a router it give a reply,
we dont get reply, if we ping a local computer with its private IP of a particular network,
So is there a way so I can make direct connection or socket with a particular PC in a network.
I have heard that, I have to make connection with public IP of a particular network and the port number will decide, on which PC in that network , my request will go.
But this method is not working..
If the computer is behind a router that uses Network Address Translation (NAT) - that is, the computer has a private IP that is not visible to the internet - then you cannot ping or establish a connection to the computer from the outside. This is because the router does not know which computer you want since all the computers behind the router share the same public IP address.
The way to establish a connection in this case is to have the computer which is behind the router establish the connection to the outside computer. For example, when you go to a web site, you can do it from a computer behind a router since your computer is initiating the connection. However, the web server you are going to must have a public IP.
When a computer behind the router initiates a connection, the router does select a port number to associate with that connection so packets from the outside for that connection will go to the right computer. However, this only works for traffic on that particular connection; the port number is not a general purpose mapping to that computer.
Two computers behind the same router can establish connections with each other using the private IPs as they don't have to go through the router to do it.
You can decide with your friend who is going to be the client (the one initiation the TCP connection) and who is the server (the one receiving the TCP connection) and which port should be used (let's say X). Let's say that your friend is the server. Then he/she has to configure his/her router to redirect all the traffic to the router to port X to his/her private IP to port X (this is what Warren mentioned as NAT).
If you use a port above 1024, the server (running on your friend's PC) doesn't need root/administrator privileges.
Your program (the client) would then connect to the public IP address of your friend. He/she can check his/her public IP with: What is my IP
I am confused about TCP/IP Socket Programming. I know the internet protocols but in theory...
I am explaining my problem (what i need )
I have a server working on X.X.X.X IP Adress. And it always listens to Y PORT.
When i want to connect that server on MY PC, i have no problem because i wrote the ip adress (X.X.X.X) and the port (Y) and my PC connects..
When i connect to server server keeps my ip adress and my local ip adress.. After that connection is end.
Here is my problem starting...
As i sad my server knows my local PC informations. How can i connect to my local PC on server my web server and sent TCP or UDP packets ? I did port forwarding on my modem but i dont want it. When i did port forwarding there is no problem but i dont want it ...
Thanks for replies and sorry for my engislih if i have mistakes .
If a router/NAT sits between your server and an outside client, you MUST use port forwarding on the router. The outside client will NOT be connecting to your server's private LAN IP/Port directly, it will be connecting to the router's public WAN IP/Port instead. So the router needs to know to forward inbound packets to that IP/Port to the server's private LAN IP/Port.
A client running on your local PC is able to connect to the server because they are both on the same LAN side of the router, so the connection is direct and does not go through the router's WAN. That is not the case for clients that are on the WAN side of the router.
I am having problems connecting to my website from a source outside my local network. I had another server before running the same site. The only difference is the old one was FreeBSD and now I'm trying it on Linux.
Here is my setup: I'm using Apache2. The server is behind a Netgear router. I'm using a Freedns host name. I have ddclient updating my ip.
Here is what happens: I can look at my site from the server in Chrome or my phone connected to the local wifi. It works using either the host name or ip address. It does not load from my cell phone or from my desktop using a proxy for either the host name or the ip address (the external one from googling my ip and from the router's wan info page). When I try the proxy with the host name I get "conection timed out" error, and when I try the ip address I get "couldn't connect to host error".
Here is what I've tried: I enabled port forwarding to the server from and to port 80 to my lan ip address. I disabled the firewall on the server. I double checked that the host name is directed to the right ip address. I ensured that the ip address does indeed point to my router. I've watched wireshark on my server while trying to connect and don't see any incoming requests when I try to load it from my phone.
It seems like maybe my port forwarding isn't working, but on my router it says that that port forwarding rule is active.
I'm out of ideas as to why what else could be going wrong.