I have a Moto G3 Turbo with Android 6.0.1 Marshmallow. I use the phone to make WiFi hotspot so I can use internet on my laptop.

I was able to do a successful Metasploit over WAN/Internet, and for that I need to port-forward to my laptop. But the problem is, I don't have any modem or router to actually go to setting login with admin password or anything like that.

What can I do? Is there any app that can do this and whether it needs root permission?

  • 4
    Generally you can't, not because Android isn't capable, but because in general carriers don't allow inbound traffic of any kind to mobile devices. You may get an IP address from your carrier, but that is just for outbound traffic, unsolicited inbound traffic (the kind you need port forwarding for) is nearly always blocked by every carrier world-wide. Add to that most carriers don't give you a public IP anyway, so even if you did get port forwarding to work, you likely couldn't use it.
    – acejavelin
    Commented Feb 4, 2017 at 14:46
  • That's not true, if your application could not receive inbound traffic how you getting message to your phone. Commented Nov 2, 2017 at 2:35
  • 4
    @ShawnThomasRheal by opening an outbound connection and keep it open for replies. That's what most apps use GCM for – so not every app has to keep its own connection open.
    – Izzy
    Commented Nov 2, 2017 at 7:18

2 Answers 2


In most cases you won't be able to make inbound connection when using Mobile Data because of CGNAT and firewalls at ISP level, as explained by acejavelin in comment. To know the problem in detail and how it can be worked around see How to connect to Android through SSH over 3G/4G public IP?

However if you can reach your phone from internet, extending this access to a connected host (PC in your case) is not a problem. Port forwarding is done with routers, and when being used as a Wi-Fi hotspot (or with USB tethering), your phone is in fact acting as a router.


In order to forward port, you need to do Destination Address Translation (DNAT) using Linux kernel's builtin firewall userspace tool iptables.

First make sure that kernel is configured to forward internet traffic (already set when hotspot is ON):

~# echo 1 >/proc/sys/net/ipv4/ip_forward

Let's say the IP address assigned by hotspot to PC is and you want to forward SSH default port (22):

~# iptables -t nat -I PREROUTING -p tcp --dport 22 -j DNAT --to

This is the simplest form of Port Forwarding.

If default POLICY of FORWARD chain in FILTER table is not ACCEPT, define rules explicitly to accept the forwarded packets:

~# iptables -I FORWARD -p tcp -d --dport 22 -j ACCEPT

Also accept outbound forwarded traffic if needed.


On non-rooted devices you can use adb or some other minimal TCP/UDP server like netcat or socat for port forwarding. Note that this won't work for ports under 1024. To forward port 2222:

~$ adb reverse tcp:2222 tcp:2222

Or on phone:

~$ nc -lk -p 2222 -e nc 2222

* nc is a busybox applet. But make sure that you get the right binary, there are multiple implementations of netcat.
* Use -u option to forward UDP port.

However nc accepts only a single connection at a time. Use socat or ncat for more advanced options, e.g. from Termux:

~$ socat tcp-l:2222,fork,reuseaddr tcp:

See Using netcat for port forwarding.

There are also apps like Fwd (it's open-source, I have no affiliation) meant for port forwarding.


  • However if you can reach your phone from internet. What do you mean by this line. How do I know whether I can reach internet or not? Commented Jun 29, 2020 at 12:05
  • 1
    @AkashKarnatak see the line above: How to connect to Android through SSH over 3G/4G public IP? Commented Jun 29, 2020 at 17:07
  • 1
    Wasn't able to do that through 'adb reverse' (although it should work from what I've read), but ncat worked beautifully right from the first time! I am already running multiple instances of it, for redirecting multiple ports, like RDP and SMB. Commented May 26, 2021 at 16:56

Irfan Latif has a detailed answer of how to and if you can do it in the correct, efficient, and maintainable way.

Possible solution/workaround

That being said, if you are not able to do it the proper way, and want a hack/workaround, you can host anything without port forwarding using Tor, works good enough for personal use but do be aware that using hidden services is significantly slower than not using hidden services, so only do this if you really have to.

A 10-minute YouTube video can help you set up a hidden service with a URL that hits a port on your device, from there you can nginx your way around to host multiple things. you can use a DNS to make your domain easier to remember, you'll still need TOR to connect to it, but you can also set it up in such a way where you don't need TOR on the client machine, Cloudflare can forward onion routs or you can use tor2web which is dead simple to use and pretty cool, but then you are relying on anonymous contributors to reroute your traffic.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .