Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-20-2010, 05:42 AM   #1
Registered: Jul 2008
Posts: 90

Rep: Reputation: 17
how to connect to port of computer which behind router

Greetings to all

Friends people with more knowledge than me ( and sense) can help to troubleshoot it.
When one should try to connect to port 3306 of particular ip here e.g. 345.56.67.87 it should be redirected to port 3306 of internal machine.
This is the scene : How can I access the particular port of the machine which is behind the router . i.e. From out side internet I would like to connect to the port 21 of the machine ( which is behind router (345.56.67.87) .
Here are the details I tried :
both side linux (centos)
1. enabled ip forwarding of router (345.56.67.87)
2. enabled ip forwarding of machine (
3. implemented some iptable rules: /sbin/iptables -t nat -A OUTPUT --dst 345.56.67.87 -p tcp --dport 3306 -j DNAT --to-destination
4. iptables -t nat -A OUTPUT --dst 345.56.67.87 -p tcp --dport 3306 -j DNAT --to-destination

I tried to google on it mainly it dealt with the iptable rules. of which i applied but error is" can not connect to the port 3306 of"
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 11-20-2010, 06:06 AM   #2
Senior Member
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Stretch (Fluxbox WM)
Posts: 1,389
Blog Entries: 52

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
If you are able to change the router, then you only need to forward the port in the router (eg 3306) to the IP of the machine on the local network (eg You don't need the iptable rules on the local machine, since it doesn't have direct access to the internet, so cannot do any network address translation (I'm presuming your router is the gateway).

When connecting from outside, you don't connect to (since that is not the external address), but to the router IP (eg, or whatever it is). The router will transparently forward the traffic to the computer on the local network (and return replies).

Last edited by neonsignal; 11-20-2010 at 06:08 AM.
2 members found this post helpful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fedora 10 com1 port will not connect to router console port using minicom rgjr979 Linux - Newbie 4 12-28-2009 06:35 PM
DSL, trying to connect to internet w/ Lynksys router and USB 1.0 port. linuxnewbie2425 Linux - Newbie 1 12-29-2008 11:54 AM
redirect printer output on computer 1(Win2000) to Computer 2(Ubuntu)via parallel port dmarkd Linux - Hardware 2 12-01-2008 04:51 AM
Connect from home to a computer inside an "external" LAN using port forwarding horacioemilio Linux - Networking 1 03-07-2008 04:36 AM
network setup: connect to another computer through the router vishivishi Linux - Networking 6 04-23-2006 08:05 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:56 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration