Port Forwarding – Sometimes we have to run our website or localhost server on the internet. To do this, we need to forward our port for other devices to access our website from anywhere in the world through the internet. Usually, we can forward our port by configuring the settings in the router, but if we don’t have a router, or if we don’t want to use our router, or if we have a static IP address, we have a very simple option.
How To forwarding Port
PHP Port Forwarding
First, you choose a website HTML file or PHP file then open the terminal inside the website file and execute the below command To find your IP address
sudo ifconfig
After that type the below command in your terminal to forward your port
USAGE: PHP -S (your Ip address: port number)
php -S 192.168.10.100:80
Now you will get one listening URL just open that URL to see your file hosted on the internet
The Servo Method
This method is also very simple, just type the following command to forward the port or host your website
Usage: ssh -R (port: Ip address: port) serveo.net
ssh -R 80:192.168.10.100:80 serveo.net
After executing the above command our localhost forward to a unique URL
After closing, you type the same command to again forward but if you need to bring that same forwarding URL means to type the below command
ssh -R lente:80:192.168.10.100:80 serveo.net
You can also forward random ports with the following command
ssh -R 0:192.168.10.100:80 serveo.net
Using Localhost.run Method
Well, it is almost similar to serveo.net then why are we adding this? Because these free services sometimes go down during overload on the server. If one service is not working then we can try another. So we can use it by applying the following command
ssh -R 80:192.168.10.100:80 ssh.localhost.run
إرسال تعليق