Access your LAN behind a 4G router, from the outside, with ngrok
Because of the finite IPv4 address, the ISPs in some countries/regions provide private IP addresses as WAN IP for 3G/4G network. For this reason, it is not possible to open ports and access devices in LAN like NAS,IP camera or Web server ...
If you want to access certain equipment on your LAN, several techniques can be used and ngrok is one of them.
Here I'll share how I've managed to access my web server behind Archer MR600 using ngrok :
To implement this solution, you must:
1- Create an account on ngrok.com (optional)
2- Install the ngrok client on the machine, in my case it was a linux machine, but the instructions are easily transposed to another PC / OS.
1- Install ngrok :
wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm.zip #download
unzip ngrok-stable-linux-arm.zip #unzip
rm ngrok-stable-linux-arm.zip #delete the zip file
2- Configure the authtoken : (optional) the authtoken can be found in your dashboard after creating the account
./ngrok authtoken xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
./ngrok http 80
** my server was running on port 80 , you must change the port number if you server is running on another port
ngrok will display a UI in the terminal with the public URL of the tunnel and other status and metrics information about connections made over the tunnel.
4- access the server with the forwarding URL
That’s it – quick and easy
What if you want to access other devices like a NAS ?
In this case you must run ngrok on a machine that will route the traffic to other device in LAN ,
for example if you want to access the Web GUI of your NAS ,you can setup ngrok on a Raspberry Pi or a PC , then execute the following command:
ngrok http 192.168.0.100:80
where 192.168.0.100 is the IP of your NAS , and 80 is the port number.