You are currently viewing Ngrok – Port Forwarding Without Router
<span class="bsf-rt-reading-time"><span class="bsf-rt-display-label" prefix=""></span> <span class="bsf-rt-display-time" reading_time="3"></span> <span class="bsf-rt-display-postfix" postfix="min read"></span></span><!-- .bsf-rt-reading-time -->

Ngrok – Port Forwarding Without Router

This article aims to be a comprehensive guide on installing and setting up ngrok tool in your system. In this article, I will show you a simple method using which you can enable port forwarding without a router using ngrok tool. So let’s get started.

Introduction

ngrok is an open-source utility for exposing localhost ports to the Internet. It works by tunneling TCP/IP traffic over an encrypted HTTPS connection through its own encrypted proxy server. You can use it to securely expose any port number on your computer to the outside world without needing root privileges. ngrok allows you to expose a web server running on your local machine to the internet. Just tell ngrok what port your web server is listening on.

Easy to Install and Use

You’ll need to download the latest version of ngrok from their website. Once downloaded, extract the archive file using your favorite archiving tool (I recommend 7zip). Navigate to the folder where you extracted the archive and run the executable. Follow the prompts to complete the installation.

To run ngrok, run the following command:
$ ngrok HTTP 80

When you start ngrok, it will display a UI in your terminal with the public URL of your tunnel and other status and metrics information about connections made over your tunnel.

Configure ngrok 

After installing ngrok, navigate to the directory containing the ngrok binary. Open the configuration file at config.json in your preferred text editor. Edit the following settings:

  • `http_port` – The port number you want to expose.
  • `https_port` – The secure port number you want to use.
  • `external_interface` – The IP address you want to bind to.
  • `internal_ipv4` – The IPv4 address you want to bind ngrok to.
  • `external` – Whether you want to allow external connections. If set to true, ngrok listens on all interfaces. If false, only listen on the specified interface.
  • `auth_token` – An optional authentication token. If not provided, ngrok uses the default auth token.

Installing your Authtoken

Many advanced features of the ngrok.com service described in further sections require that you sign up for an account. Once you’ve signed up, you need to configure ngrok with the auth token that appears on your dashboard. This will grant you access to account-only features. ngrok has a simple ‘authtoken’ command to make this easy. Under the hood, all the auth token command does is to add (or modify) the auth token property in your ngrok configuration file.
$ ngrok authtoken <YOUR AUTHTOKEN>

Password protecting your tunnel

Anyone who can guess your tunnel URL can access your local webserver unless you protect it with a password. You can make your tunnels secure with the -auth switch. This enforces HTTP Basic Auth on all requests with the username and password you specify as an argument.
$ ngrok http -auth="username:password" 80
Your tunnel is now protected using HTTP auth. Noone’s spying on your business!

It has a dashboard

When you start up ngrok it shows you the URL you are tunneling through and another local URL, http://127.0.0.1:4040.The dashboard allows you to see the status of your tunnel, and the requests you have made through it, and the responses that came back from your application.

You can replay requests

Take a look again at that dashboard. Not only can you inspect requests that came through the ngrok tunnel, but you can also replay them. Now when you’re API endpoint is misbehaving, rather than sending another message and then another message until you get it right, you can just replay the incoming request from the dashboard.

Conclusion

So, this guide is about installing and configuring the ngrok tool. Now using the above steps you can enable the port forwarding on your local system without a router. Hope you like this cool trick, do share this trick with others too. Leave a comment below if you have any related queries about this.

Piyush Kumawat

Ethical Hacker || Penetration Tester || Gamer || Blogger || Application Security Engineer

Leave a Reply