How to open a publicly accessible port? - server

I run a server (Photon) on my pc and it uses port 9090.
I can access it with the local IP address, with the IP address of the internal router network but not the public one. Even through this public IP address pings perfectly.
To run the server publicly I DON'T use a router but direct connection. All possible firewalls are disabled, no antivirus, all ports in Inbound Rules are opened (just in case). But still telnet xxx.xxx.xxx.xx 9090 gives me Could not open connection to the host, on port 9090: Connect failed.
If I enter netstat -aonb into the cmd I see that
TCP    0.0.0.0:9090                    LISTENING
What means that it must be listened for any IP address (0.0.0.0) on port 9090, as I understand
But port 9090 is still closed, as online services say. And if I try to connect to the server from the client (as it works for internal network) I get Error: 1004 Master peer error timeout
What else can I do to open this port and to finally get it accessible via public network?
I use Windows.

The description of the problem seems inconsistent. Most likely, the claims that "All possible firewalls are disabled [... and] all ports in Inbound Rules are opened" are one or both incorrect or misleading.
If
the test client can successfully ping the destination machine, and
netstat shows that a client is listening to 0.0.0.0:9090 / TCP on the destination machine, but
the test client cannot connect to port 9090 at the same address, and
test clients can successfully connect to port 9090 on the destination machine via others of its addresses, both before and after
then by far the most likely scenario is that the failing connection attempts are being blocked by a firewall. Even if no firewall at all is running on the server itself, there may be one running on a router on the network path between client and server. Note that router firewalls often distinguish between internal traffic and external, applying stricter controls to the latter. Some have entirely separate rule sets for the two.

Related

How to set up a client/server connection using port forwarding

I created a multi-threaded client/server application that can send messages to each other at real time. Everything works perfectly, but I want to be able to send messages over the Internet. From what I understand, I need to do port forwarding to be able to make my server reachable for the clients. I then set up my port forwarding options by providing a port (9991) and then my Macbook Air's IP Address (192.168.0.1).
I then tried to connect to my server using my public server IP (let's say 197.132.20.222) and it didn't work. I then tried to see if the port forwarding worked by using this website: https://www.yougetsignal.com/tools/open-ports/ and I realized that the connection was closed. I also tried the command nc -vz 197.132.20.222 9991 while running my application and the connection is refused.
I'm using a JavaFX application, and for my server side I use a ServerSocket with port 9991. For the client side, I use a Socket and set the IP Address to my public router IP Address, and I tried to connect with another PC using mobile data to use a different network.
My firewall settings are turn off, so I really don't know what is blocking my application to connect to that port. Could it be my ISP is blocking connections? I just don't understand why my ports are blocked even with no firewalls enabled.

An attempt was made to access a socket in a way forbidden by its access permissions on port 80

I have my own web site hosted on a dedicated server. I have 2 IP addresses set up.
One is for my web server and the other is for my web socket.
I did this so that my web socket clients can access my server using port 80.
However, when I run my server application I get the error:
An attempt was made to access a socket in a way forbidden by its access permissions
Now if I switch it to a different port it works (which I have allowed through the firewall). There is nothing entered in the Windows Logs.
I am running as an Administrator. I am using Windows server 2012.
Is there anything I can check?
I checked using netstat etc but this IP address is not being used on port 80 anywhere else
I have 2 IP addresses pointing to my server hosted at FastHosts.
So I have a web site (using IIS)
Originally I had a web socket connection/listener listing on port 8090.
I had created a rule in my firewall settings to allow access to this connection.
Indeed for over a year now I have been using this connection using port 8090.
It occurred to me last week that using a clients PC that they could not access the socket over port 8090. I assumed because of firewall issues.
So, I figured if i switched to port 80 for this socket it will not need an exception to that clients firewall rules.
The trouble is I cannot have a web server listening on port 80 and a web socket so I purchased another IP address from my host and 'added' to my network adapter.
I have made sure nothing else is using port 80 for this new IP address. But I get the access denied
As a test I created a default.html page which said 'hi' all with no issues. I then 'stopped' the web server for that IP address

How Can I ping or create a scoket connection with my friend?

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

Client and Server public IP

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

Can't connect to my webserver from external source

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.