Custom Search

Thursday, January 31, 2013

How to do port forwarding with socat simple example




Socat is a command line based utility that establishes two bidirectional byte streams and transfers data between them.

===========================

* Openstack Cloud Service Listening on port 8773 by default
http://192.168.12.222:8773/services/Cloud

* Openstack dashboard/horizon/apache2 Listening on port 80 by default
http://192.168.12.222

===========================

How to forward connection to port 8000 to port 8773 (port of Openstack Cloud Service) using port forwarding
-----------------------------------------------------

* Goto Openstack server and run following command
* Here socat waits for a connection to port 8000 and forward it to port 8773 of same machine.
#sudo socat TCP-LISTEN:8000,fork TCP:localhost:8773

* Open following URL in the browser tocheck port forwarding from 8000 to 8773
http://192.168.12.222:8000/services/Cloud

===========================

How to forward connection to port 80 to 8773 (port of Openstack Cloud Service) using port forwarding
-----------------------------------------------------

* Here socat waits for a connection to port 8000 and forward it to port 8773 of same machine.
#sudo socat TCP-LISTEN:80,fork TCP:localhost:8773

===========================

* Find Out Which Process Is Listening(Open) on Port 80
#sudo netstat -tuplen | grep 80

===========================

* Stop apache2 and close the port 80
#sudo /etc/init.d/apache2 stop

===========================

* Check whether port 80 is Open or Close
#sudo netstat -tuplen | grep 80

===========================

* Here socat waits for a connection to port 80 and forward it to port 8773 of same machine.
#sudo socat TCP-LISTEN:80,fork TCP:localhost:8773

* Open following URL in the browser to check port forwarding from 80 to 8773
http://192.168.12.222/services/Cloud

===========================

* Start apache2 and open port 80

#sudo netstat -tuplen | grep 80
#sudo /etc/init.d/apache2 start
#sudo netstat -tuplen | grep 80


* Open following URL in the browser to check whether apache is Listening on Port 80
http://192.168.12.222

===========================

No comments:

Post a Comment