WebSocket-Sharp doesn't respond to public IP address - http

I have a problem hosting WebSocket-Sharp on a public internet IP. Locally it works fine.
This problem occurs on Windows and Linux.
I do no receive a timeout or an HTTP status code, the page blocks immediately.
I'm 99% sure I have port forwarding set up correctly; I've tried with an Android modem, VPN and regular NAT router setup.
I've tried the following combinations:
192.168.1.2:80 8080 5000 39393
0.0.0.0: ....
public IP: ....

The problem resides in the HttpServer provided with WebsScketSharp. The pure websocket variant (WebSocketServer.cs), instead of the HttpServer option with Get functionality, has an option to set AllowForwardedRequest to true so will be reachable from non localhost addresses. The HttpServer class doesn't support this.
It is partially a solution as I gave up regular GET functionality, but thats fine by me.

Ok, assuming your server with the public Ip addres is Linux:
Check what ports are listening and what program are listening in those
netstat -tulpn
Check your Firewall rules both in the provider and in the Server
sudo ufw status
See if connections are getting to your Server
sudo tcpdump
You can filter for the port of for origin Ip (if you use a proxy that will be different Ip).
sudo tcpdump | grep "80\|123.45.67.89"
That's the only way to see if the packets are getting into the server.
Let me know if you use Docker as thinks work a bit different.
You can create a tunnel and try like if it was local
ssh -L 80:123.45.67.89:80 ubuntu#yourserver.com
Cheers

Related

How to create TCP tunnels with Pagekite

I am a complete beginner when it comes to networking and I am trying to set up a TCP tunnel on my machine using pagekite. I want to route all traffic from a TCP address to a port on my localhost, let's say 8080. I would then start a handler on localhost:8080 to deal with the incoming traffic. I can get this to work with ngrok simply by doing ngrok tcp 8080, but on a free ngrok plan I cannot reserve tcp addresses and ngrok is rather slow, so I opted to try and use pagekite.
Pagekite normally allows easy tunnelling to an HTTP address, but they have a guide here about how to use PuTTY along with Pagekite to create a TCP tunnel proxied by HTTP.
I followed their guide but could use some help figuring out if it does what I want it to do.
I am working on a Linux VM, so I first set up an SSH server with openssh like this: sudo service ssh start
I then exposed that SSH server using pagekite like this: python3 pagekite.py 22 ssh:user.pagekite.me
I then started PuTTY, and configured the Host Name to be user.pagekite.me on port 22, setup an HTTP proxy with the proxy hostname user.pagekite.me on port 443 and finally created a tunnel from the PuTTY machine with source port 8080 and destination localhost:8080.
Now I am not sure what this actually accomplished. I know that the PuTTY machine connected to the ssh server running on my VM and I am able to use the linux terminal from the PuTTY terminal but has this actually created a TCP tunnel from user.pagekite.me:8080 to localhost:8080? Additionally after doing this, if I try to setup the handler on localhost:8080 I get the following error:
Handler failed to bind to 0.0.0.0:8080
Rex::BindFailed The address is already in use or unavailable: (0.0.0.0:8080).
Again I am completely clueless when it comes to networking so if anyone could explain what it is I'm doing and if it is even possible to do what I want the way that I am doing it, that would be quite helpful.

SSH No Route to Host

I apologize for the novice question, but have been struggling on this for many hours. I am running Ubuntu Server on Ubuntu 16.04. I can ssh fine into local host (thus know ssh server is running)
However, when I try to log into my server externally, I get the error message shown below (yes I know port 22 is not secure):
I have enabled port 22 on my /etc/ssh/sshd_config file and allowed the ListenAddress to be everything by leaving it empty (tried with other addresses), and ensured that my iptables are open:
Finally, I am using a static IP address. And ensuring that I am forwarding ports:
I am not including a port triggering as I do not believe that it is necessary?
What do I need to do to expose this server externally and be able to SSH into it? Any help is very much appreciated.
Solved, no responses required. My internal ip address that I had my port forwarding selected for was different than the internal ip address that my computer was on.

NETSH port forwarding from local port to local port not working

I'm trying to use NETSH PORTPROXY command to forward packets sent to my XP PC (IP 192.168.0.10) on port 8001 to port 80 (I've a XAMPP Apache server listening to port 80).
I issued the following:
netsh interface portproxy add v4tov4 listenport=8001 listenaddress=192.168.0.10 connectport=80 connectaddress=192.168.0.10
Show all confirms that everything is configured correctly:
netsh interface portproxy show all
Listen on IPv4: Connect to IPv4:
Address Port Address Port
--------------- ---------- --------------- ----------
192.168.0.10 8001 192.168.0.10 80
However, I'm not able to access apache website from http://localhost:8001. I'm able to access through the direct port at http://localhost as shown below.
Additionally, I've also tried the following:
1. Access the Apache website from a remote PC using the link: http://192.168.0.10:8001. Firewall turned off.
2. Changing listenaddress and connectaddress to 127.0.0.1.
Without further information, I can't find a way to resolve the problem. Is there a way to debug NETSH PORTPROXY?
Note: By the way, if you're wondering why I am doing this, I actually want to map remote MySQL client connections from a custom port to the default MySQL Server port 3306.
I managed to get it to work by issuing:
netsh interface ipv6 install
Also, for my purpose, it is not required to set listenaddress and better to set connectaddress=127.0.0.1, e.g.
netsh interface portproxy add v4tov4 listenport=8001 connectport=80 connectaddress=127.0.0.1
If netsh's port proxying is not working as expected, then you should verify the followings, preferably in that order:
Make sure the port proxy is properly configured
Start or restart the related Windows service
Ensure support for IPv6 is installed
Make sure the port is not blocked by a firewall
Make sure the port proxy is properly configured
This might seems to be trivial, but just in case, take the time to review your configuration before you go any further.
From either a command prompt or PowerShell prompt, run the following command:
netsh interface portproxy show all
The result should look something like this:
Listen on ipv4: Connect to ipv4:
Address Port Address Port
--------------- ---------- --------------- ----------
24.12.12.24 3306 192.168.0.100 3306
24.12.12.24 8080 192.168.0.100 80
Carefully review those settings. Make sure that you can indeed connect to the addresses on the right side of that list, from the local computer. For example, can you locally open a web browser and reach 192.168.0.100:80? If the protocol is not HTTP, then use telnet: telnet 192.168.0.100 3306 (see here for how to install the Telnet client on Windows).
Then, are the values on the left side correct? Is the IP address valid for your machine? Is that the port number you are trying to connect to, from the external machine?
Start or restart the related Windows service
On latest versions of Windows, netsh's port proxying is handled by a Windows service named "IP Helper" or "iphlpsvc". Proxying will obviously not work if that service is stopped. I have also faced situations that turned out to be resolved by restarting that service.
To do that in latest versions of Windows:
Open the Task manager, then go to the Services tab.
In the "Name" column, find the service named either "iphlpsvc" or "IP Helper".
Right click on that service, then select Restart. If restart is not available, then the service is probably stopped, and actually has to be started, so select Start.
On previous versions of Windows, look for Services in Administrative Tools, inside the Control Panel.
Ensure support for IPv6 is installed (older releases of Windows only)
On earlier versions of Windows (that is Windows XP, for sure, upto some early releases of Windows 10, apparently, though this is not clear), netsh's port proxying feature (including for IPv4-to-IPv4 proxys) was actually handled by a DLL (IPV6MON.DLL) that was only loaded if IPV6 protocol support was enabled. Therefore, on these versions, support for the IPv6 protocol is required in order to enable netsh's port proxying (see Microsoft's support article here).
From either a command prompt or PowerShell prompt, run the following command:
netsh interface ipv6 install
If you get an error indicating that command interface ipv6 install was not found, then it means that you are using a recent release of Windows, in which netsh's IPv6 support is implicit and cannot be disabled.
Make sure the port is not blocked by a firewall
A local firewall may potentially block the port even before they reach the IP Helper service. To make validate this hypothesis, temporarily disable any local firewall (including Windows' native firewall), then retest. If that works, then simply add a port exclusion to your firewall configuration.
I have the problem with you. I have solve it just now. There is a Windows Service named "IP Helper" that supplies the funcions tunnel connections. You should ensure it has been started.
You must Run Command.exe as Administrator first, by right-clicking the Command Prompt icon and choosing Run as Administrator. You will asked to confirm.
Paste your netsh Command in the command.exe window and press Enter.
If no error message is shown, the command worked.
In your web browser go to http://your-up:8001 to see it works.
The Windows Event Log might have information to help find the cause of a failure.

How to try out HTTP, FTP, SMTP etc. application protocols

I am reading Computer Networking: A Top-Down Approach 5th (fifth) edition. I have reached chapter two and I wonder if it is possible to actually try out the different application protocols by writing the requests etc? I am using Windows if that matter if you need a tool for doing that, and if I need a tool, what does the tool do behind the scenes for connecting?
You should use telnet to connect to all of these protocol, do your request, reading the answer and so on.
I'm reading that telnet is disabled by default on newer windows version (unbelievable, why? Thank goodness I stopped using it!)... Follow this guide to re-enable it if you're using a windows version newer than xp.
Telnet was used to remotely login to a host. Today it's completely unsafe to use it in this way, as long as a telnet connection isn't encrypted and we have such a better tool like ssh for remote connection. However, you can think to Telnet as a generic TCP client. It can establish TCP connection on every port.
By default, it will try to attempt to connect to port 23 (that is the telnet port) but you can easily change that.
For example, if you want to test HTTP, you can write in your command line:
~$ telnet www.example.com 80
Trying 192.0.43.10...
Connected to www.example.com.
Escape character is '^]'.
Where 80 is the http port (of course, if you're running it locally, you should connect to localhost). Other lines state the connection is ready to receive a request. Now you can type any http command you want.
GET /
HTTP/1.0 302 Found
Location: http://www.iana.org/domains/example/
Server: BigIP
Connection: close
Content-Length: 0
Where GET / is the command I typed and the rest is the http response.
Changing the port number, you can speak to (almost?) every protocol in the internet.
Well you can them out like this.... just to name a few...
Ftp : ftp ip_addr or ftp domain_name
Telnet : telnet ip_addr or telnet ip_addr:port_no or tracert domain_name
tracert : tracert ip_addr or tracert domain_name
ping : ping ip_addr or ping domain_name

Basic OpenPGM Setup

I've recently begun to setup OpenPGM on a threesome of virtual linux machine with a fourth virtual machine acting as a gateway. Ideally I would like to observe the traffic using wireshark on the gateway. At this stage I'm only using the sample applications ( pgmrecv and pgmsend ) which operate as expected, but as soon as I set a static IP on a machine running pgmrecv, it errors and aborts iteself with the message:
** ERROR **: parsing network parameter: Unique address cannot be determined for interface 'eth0': Internet host resolution: Temporary
failure in name resolution(-3) aborting... Aborted
BTW, eth0' is the interface I am listening on, and there is no dhcp server involved in this network. Also, the gateway has port forwarding turned on.
I can ping between any of the machine in this virtual network with the static IPs.
Does anybody with experience with openPGM understand the cause of this error. How would assigning a static IP cause this?
I apologize if this is a rudimentary question; I am new to openPGM and could not find information on this issue posted elsewhere.
Thanks in advance.
While I cannot explain the error message, I found that using the local IP address of the box as the argument passed with -n caused pgmsend and pgmrecv to function on a box with a static IP address.
If your eth0 ip address is 192.168.1.1 then you set openpgm reciever in this way:
sudo ./purinrecv -lp 7500 -n "192.168.1.1;239.192.1.1"
and sender in this way:
sudo ./purinsend -l -n "192.168.1.1;239.192.1.1" -p 7500 test_msg

Resources