Forwarding a port

Started by Trickyrick, February 04, 2021, 06:25:25 PM

Previous topic - Next topic

Trickyrick

I have an app on my android phone that's supposed to send info to a program running on a local computer
In the app, I've filled in the WAN IP and the port
On my router, I've used port forwarding to forward TCP port 55555 to an IP on my network.
It's not working.
I don't know how to diagnose the problem
I use Norton on Windows 10 I've made sure that Norton is not blocking the port
Any ideas

Dieselboy

Hi trickyrick
Just to relay this so that you can be sure that I understand - you have an app on your phone which should send data to an application running on your computer.
Are there any other components involved?

If both the phone and computer are on the same private network then you probably don't need to change any router configuration.

The computers application will need to be open and running and you can check it has opened a port on your computer by using the `netstat` command. If you use `netstat -an` you should see the the listening port there.

On the phone app I assume you would need to save the computers local IP address into the app. along with the port.

At this point you would have:

Quotephone -> computer IP:port

Regarding the computer, you may need to allow the incoming traffic through any software firewall that you have running. You can test if the computer is open and listening by using another computer on the same network and some CLI:
Quotetelnet computer-IP port

replace "computer-IP" and "port" exactly as is above. When you press return, if the computer is open and accepting connections then the command prompt window will go blank to show that it is connected and waiting for telnet data to be received. Since this isnt telnet, we're just looking for this response rather than data. If the port is not reachable then you'll just see "connecting...." message before "connect failed"

Let me know how you go :)

Trickyrick

Thanks, Dieselboy
The app is for location (EventGhost) so the phone is not on the network so I point the app to my WAN ip address and thats y I need the port forwarding.  So I used your netstat and it said it was listening and when I used your Telnet (on another computer) the screen goes black so do I assume that I'm connected to the computer.  I guess I should try the same thing from another location

Dieselboy

I think I understand. So you want the traffic to go like this:

phone 4G -> internet -> home router > server

Key components:


  • Home router public IP
  • server IP and port:(55555)

Now work out which way you want to do the port forwarding. If your server is listening on 55555 then I'd recommend having the same port forwarded from the home router to the server. So it would look something like this:

phone 4G -> internet -> home router port 55555 > server port 55555

///


Which type of router/firewall do you have? You may need to create a custom "game or application" to allow the port 55555 through. You would need to enter in the IP of the "server" and the port. If you use the same port on the router WAN then it may be simpler because then you just enter port 55555 in both places.

To troubleshoot, you can do the same telnet test while using hostpot or internet sharing from your phone and use a laptop with wifi or something along those lines so you can use a laptop in place of the phone but do the same test. This time around though you'll need to use your public IP instead of the private IP. Let's say your public IP is 202.3.3.3. Then just use that IP in the telnet test with the port 55555 like before: `telnet 202.3.3.3 55555`. If the screen goes blank again then you're all set. If not, then the router is not allowing it through. If this happens, maybe try removing anything which you've put in to get this working and starting over with just the one port forward rule. Rules are usually evaluated top-down. Else post back and I'll try and help :)

deanwebb

I do the same thing with a Minecraft server. On the network, we connect to the local IP address on the Minecraft port. Friends outside my house connect to the external IP address of my Internet router on the Minecraft port.
Take a baseball bat and trash all the routers, shout out "IT'S A NETWORK PROBLEM NOW, SUCKERS!" and then peel out of the parking lot in your Ferrari.
"The world could perish if people only worked on things that were easy to handle." -- Vladimir Savchenko
Вопросы есть? Вопросов нет! | BCEB: Belkin Certified Expert Baffler | "Plan B is Plan A with an element of panic." -- John Clarke
Accounting is architecture, remember that!
Air gaps are high-latency Internet connections.

Trickyrick

This is what i did
Like you suggested I created a hot spot and connected with my latptop.  I first typed in telnet then open WAN IP 55555    It just hung on connecting
Then I typed in telnet WAN IP 55555  the screen went blank and you suggest that its connected to my server but I still dont get a response (nothing happens) in the program thats running on my server.
I guess since Ive proved that my laptop is getting through to my server then its an issue with the program im using on my server

Dieselboy

Quote from: Trickyrick on February 09, 2021, 09:59:48 AM
I guess since Ive proved that my laptop is getting through to my server then its an issue with the program im using on my server


Possibly. You might be able to confirm it if you capture traffic with wireshark and then try from your phone. Install and run wireshark on the server and open it. Enable and start the capture. You can add a filter to capture only tcp port 55555 traffic with:
tcp.port==55555

When the capture is running you'll see packets being logged. When you apply the filter, you'll probably see nothing logged until you try with your phone. Once you try with your phone, I'd be checking that the traffic is coming in and looking for the reply from your server.

Otanx

Is the WAN IP in the range of 100.64.X.X to 100.127.x.x? If so you may not be able to forward the port.

-Otanx

Trickyrick

Ok thanks guys for your help.  I learned a bunch
I used Wireshark and a Telnet app on my android phone (Termius)  I was able to capture packets so the connection or port was getting through so I started to look at the app on my phone that is supposed to transmit data when I come into my Geo-Fence there is a setting there I can either use Google or PathSense (Im not sure what those do) I changed from default Google to PathSense and its working
Great
Have a good day

Dieselboy