SUPPORT THE SITE WITH A CLICK

Subscribe Rss:

SUPPORT THE SITE WITH A CLICK

Friday, January 18, 2008

Port forwarding in linux

Port forwarding (sometimes referred to as tunneling) is the act of forwarding a network port from one network node to another. This technique can allow an external user to reach a port on a private IP address (inside a LAN) from the outside via a NAT-enabled router.

Port forwarding allows remote computers (e.g. public machines on the Internet) to connect to a specific computer within a private LAN.

For example:

* forwarding ports 80 or 443 to run an HTTP webserver
* forwarding port 22 to allow Secure Shell access
* forwarding port 21 to allow FTP access

Before going for portforwarding check your machine which ports are running
Open the terminal and type netstat-ntlp.It will display like this

root@aspx-desktop:~/Desktop# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN 5214/icecast
tcp 0 0 192.168.1.230:8001 0.0.0.0:* LISTEN 5878/httpd
tcp 0 0 192.168.1.230:8002 0.0.0.0:* LISTEN 5878/httpd
tcp 0 0 192.168.1.230:8004 0.0.0.0:* LISTEN 5878/httpd
tcp 0 0 192.168.1.230:7110 0.0.0.0:* LISTEN 6149/backupserver
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 5309/mysqld
tcp 0 0 127.0.0.1:587 0.0.0.0:* LISTEN 5659/sendmail: MTA:
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 5446/smbd
tcp 0 0 0.0.0.0:5900 0.0.0.0:* LISTEN 5963/vino-server
tcp 0 0 127.0.0.1:46799 0.0.0.0:* LISTEN 4981/python
tcp 0 0 127.0.0.1:8118 0.0.0.0:* LISTEN 5423/privoxy
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 5028/cupsd
tcp 0 0 127.0.0.1:45464 0.0.0.0:* LISTEN 4957/hpiod
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 5659/sendmail: MTA:
tcp 0 0 127.0.0.1:9050 0.0.0.0:* LISTEN 5480/tor
tcp 0 0 192.168.1.230:7100 0.0.0.0:* LISTEN 6151/dataserver
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 5446/smbd
tcp6 0 0 :::22 :::*

Now in this machine some application is running 192.168.1.230:8004 .now i want to run this application in some port say 3000
now type ssh -L 3000:192.168.1.230:8004 root@192.168.1.230
after entering into the machine,type exit.now in the terminal type netstat -ntlp you will find
port 3000 is running.just check the figure below