0

I want to forward my local port outside of network as does in routers but through phone's network. I having Android 11.

I have looked many pages and fortunately found this but this seems like it does forward my local server inside my local network, I'm newbie to networking.

adb shell "ip -4 addr"

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
3: rmnet0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc mq state UNKNOWN group default qlen 1000
    inet 26.88.120.96/24 scope global rmnet0
       valid_lft forever preferred_lft forever
11: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    inet 192.168.36.69/24 brd 192.168.36.255 scope global wlan0
       valid_lft forever preferred_lft forever
26: rndis0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    inet 192.168.23.126/24 brd 192.168.23.255 scope global rndis0
       valid_lft forever preferred_lft forever

Any help/link regrading this would be grateful. Sorry if i asked wrong question.

Adarsh Raj
  • 121
  • 1
  • 7
  • 1
    As a start please read why opening a port in mobile network most likely won't work (your question is a bit unclear what you want to do, but my guess is that it is this direction) https://android.stackexchange.com/questions/203996/how-to-connect-to-android-through-ssh-over-3g-4g-public-ip/205807 – Robert Feb 03 '22 at 08:28
  • You are right, but i have a public ip (as told if you have pulblic ip you can forward) and i have done everything found on web and it does work but still cannot access from internet. :/ – Adarsh Raj Feb 03 '22 at 09:05
  • I would first test if you can make an service like ssh or http public if it is running directly on your phone. If that works you can try to forward the port into your hotspot network. If your phone is not rooted for making the iptable changes you could try to use socat. It allows to accept TCP connections and then forward them to a configured IP address similar to a proxy (but does not require root). – Robert Feb 03 '22 at 09:13
  • if i'm not wrong then : you want to say installing socat in phone-terminal and then listen for connection on my public ip and then forward to local IP? If yes then is this command is right : socat tcp-l:2222,fork,reuseaddr tcp:<ip>:80 – Adarsh Raj Feb 03 '22 at 10:49
  • can i use adb forward? – Adarsh Raj Feb 03 '22 at 11:10
  • If you have an USB connection adb forward or better adb reverse may also work. But I am not sure if it binds the open port to the mobile interface. – Robert Feb 03 '22 at 11:58

0 Answers0