LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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, 04: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, 05:06 AM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Bookworm (Fluxbox WM)
Posts: 1,391
Blog Entries: 54

Rep: Reputation: 360Reputation: 360Reputation: 360Reputation: 360
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 05:08 AM.
 
2 members found this post helpful.
  


Reply



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 05:35 PM
DSL, trying to connect to internet w/ Lynksys router and USB 1.0 port. linuxnewbie2425 Linux - Newbie 1 12-29-2008 10:54 AM
redirect printer output on computer 1(Win2000) to Computer 2(Ubuntu)via parallel port dmarkd Linux - Hardware 2 12-01-2008 03:51 AM
Connect from home to a computer inside an "external" LAN using port forwarding horacioemilio Linux - Networking 1 03-07-2008 03:36 AM
network setup: connect to another computer through the router vishivishi Linux - Networking 6 04-23-2006 07:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:35 AM.

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
Open Source Consulting | Domain Registration