Reaching homeserver from the internet via Android hotspot

I set up a simple webserver on a LAN PC connected to internet via an Android hotspot.

Previously, I did the same via a local wired router and worked out fine with simple NATting and an automatic dynamic IP checking.

I’d like to do the same again but via Android as a router, just I do not know how.
Any idea and hints?
Thank you

Hi @alimurgia,

For that you’ll have to setup port forwarding on both the router as well as the Android hotspot. I don’t know if it can be done or how to do it with/on the hotspot, so don’t know the pratice, only the theory.

Hope this helps! Although I doubt it

Well, I no longer use a “traditional” router, just tethering via Android hotspot.
Point #1 is: NATting via Android…
Any practical hint?

Nah, sorry.

But have a look here:

read but it does makes no sense to me :frowning:
I am looking for a simpler solution such maybe a couple of commands in adb… dunno…


Me neither.

I can tell you that you’ll get more help, and theoretically easier help, elsewhere, like S.O. or similar, than on the Manjaro forums though.


My first thought is - you cannot - due to how Android handles network.

While you can create outgoing traffic - but you cannot get incoming traffic routed to the tethered device.

Maybe you can find a way around it … an app perhaps, but I wouldn’t get my hopes up.


Got curious - perhaps you can get ideas from this search

I’ve also found it right now:

Looks nice… going to give a try and refer back…

5 mins later:

  • then I succeeded installing netcat in termux then typed in:
    nc -lk -p 2222 -e nc 2222
    but now netcat says wrong syntax…
  • I also gave a try to socat but then after installing it socat says no linked library found.

I would then stick to nc.
Does anyone knows the correct syntax?

In gnu-netcat, there is no -k option.
In openbsd-netcat, there is.

You apparently have gnu-netcat, so the command copy/paste will not work there.

I attempted installing vanilla netcat but termux refused yelling the only available source was netcat-openbsd.
Seemingly, this netcat complains something about the -e option…

-installed version is confirmed to be netcad-openbsd 1.21.7-2-3
-even without -k option does not want to work

nc -p 8000 8000 seems at least to be accepted (not sure working…)

you did not mention this initially :wink:

from the man page of openbsd-netcat:

There is no -c or -e option in this netcat, but you still can execute a command after connection being established by redirecting file descriptors. Be cau‐
tious here because opening a port and let anyone connected execute arbitrary command on your site is DANGEROUS. If you really need to do this, here is an ex‐

I don’t know what the person writing the post was using - or whether they simply wrote from memory without testing.

Up to now:
1-catching up android external IP is done via:
echo $(wget -qO -
I get the IP W.X.Y.Z

2-then this nc SEEMS to work (at least accepted):
nc -p 8000 8000

3-then I take another android phone, in a browser I key in W.X.Y.Z:8000 but the browser:

  • finds W.X.Y.Z;
  • complains about the destination not being HTTPS (that’s acceptable: it isn’t indeed)
  • times out;

I think nc is not yet totally right

Anyone has better commands as a safer alternative?

I think you need to understand what they mean when they call it dangerous.
In your scenario, it probably isn’t. (cave: dangerous half knowledge …)

… and an example is in that very man page, right below the excerpt I posted

I don’t know much about this - I’m here watching and learning.
I just felt prompted to respond re your syntax error issue …

Keep in mind that a lot of mobile ISPs are using CG-NAT and then no amount of port forwarding or whatever on your android will help.

Some providers allow you to change the APN so that the phone gets a public address.
I have done that in the past.

OK, so what piece of info do I have to input in the APN conf to get a public IP?

so if a digital nomad is trying to set up an "home"server (not having an home by definition) he is prevented. So no “home"servermusicstreamer - no"home”-own-chat-serverx etc.
One can only make use of a “homed” router in a fixed location!? :frowning:

Search for it or call your provider…

I guess you’d first need to find out whether your provider is one of them?

… or if you actually will have a problem with CG-NAT

I think you are jumping to conclusions too quickly.