LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 11-20-2010, 05:42 AM   #1
shridhar005
Member
 
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 (192.168.5.8) 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 (192.168.5.8)
3. implemented some iptable rules: /sbin/iptables -t nat -A OUTPUT --dst 345.56.67.87 -p tcp --dport 3306 -j DNAT --to-destination 192.168.5.8:3306
4. iptables -t nat -A OUTPUT --dst 345.56.67.87 -p tcp --dport 3306 -j DNAT --to-destination 192.168.5.8:3306


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 192.168.5.8"
 
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
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Jessie (Fluxbox WM)
Posts: 1,388
Blog Entries: 52

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
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 192.168.5.8). 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 192.168.5.8 (since that is not the external address), but to the router IP (eg 145.56.67.87, 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.
  


Reply


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


All times are GMT -5. The time now is 04:33 PM.

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