HomeLinuxLinux Easy Port Forwarding using PHP and ssh

Linux Easy Port Forwarding using PHP and ssh

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
				
			
Linux Easy Port Forwarding using PHP and ssh

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
				
			
Linux Easy Port Forwarding using PHP and ssh

Now you will get one listening URL just open that URL to see your file hosted on the internet

forwarding url

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
				
			
servonet port forwarding

After executing the above command our localhost forward to a unique URL

Linux Easy Port Forwarding using PHP and ssh

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
				
			
forward same port

You can also forward random ports with the following command

				
					ssh -R 0:192.168.10.100:80 serveo.net
				
			
servonet random ports

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
				
			
Linux Easy Port Forwarding using PHP and ssh

RELATED ARTICLES

4 Comments

  1. Thanks on your marvelous posting! I genuinely enjoyed reading it, you happen to be a
    great author.I will make sure to bookmark your blog and will come back sometime soon. I want to encourage one to continue your great job, have a nice weekend!

Leave A Reply

Please enter your comment!
Please enter your name here

Most Popular