LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-28-2011, 02:26 AM   #1
pnmanojshenoy
Member
 
Registered: Jun 2008
Location: Cochin, India
Distribution: Debian,Ubuntu
Posts: 38

Rep: Reputation: 0
Iptables Port forwarding


Hello,

I have set a rule in Iptables to do port forwarding to another Ip in

/sbin/iptables -t nat -A PREROUTING -p tcp -i eth+ -d 192.168.2.10 --dport 2200 -j DNAT --to 192.168.70.101:2200
/sbin/iptables -A FORWARD -p tcp -i eth1 -d 192.168.70.101 --dport 2200 -j ACCEPT

The redirect rule is working fine from other PC's but I am not able to do the same from the same machine in which I have configured the IPtables rule ie:

telnet localhost 2200 not working and also telnet 192.168.2.10 2200 not working from the machine whereas it redirection is working from from other PC's
 
Old 03-28-2011, 03:08 AM   #2
manyrootsofallevil
Member
 
Registered: Dec 2010
Distribution: Red Hat, Kubuntu
Posts: 130

Rep: Reputation: 14
Quote:
Originally Posted by pnmanojshenoy View Post
Hello,

I have set a rule in Iptables to do port forwarding to another Ip in

/sbin/iptables -t nat -A PREROUTING -p tcp -i eth+ -d 192.168.2.10 --dport 2200 -j DNAT --to 192.168.70.101:2200
/sbin/iptables -A FORWARD -p tcp -i eth1 -d 192.168.70.101 --dport 2200 -j ACCEPT

The redirect rule is working fine from other PC's but I am not able to do the same from the same machine in which I have configured the IPtables rule ie:

telnet localhost 2200 not working and also telnet 192.168.2.10 2200 not working from the machine whereas it redirection is working from from other PC's
What is the gateway for your PCs and what is the gateway for 192.168.2.10?
 
Old 03-28-2011, 04:08 AM   #3
pnmanojshenoy
Member
 
Registered: Jun 2008
Location: Cochin, India
Distribution: Debian,Ubuntu
Posts: 38

Original Poster
Rep: Reputation: 0
Hello,

Thank you for your reply, the Gateway for the PC and the IPtables Machine are the same. as I told redirection is working fine if I try from another machine. but I am not abke to do the same from the IPtables machine using localhost or the IP it tells connection refused.

0.0.0.0 192.168.2.1 0.0.0.0 UG 100 0 0 eth0
 
Old 03-28-2011, 04:38 AM   #4
manyrootsofallevil
Member
 
Registered: Dec 2010
Distribution: Red Hat, Kubuntu
Posts: 130

Rep: Reputation: 14
Quote:
Originally Posted by pnmanojshenoy View Post
Hello,

Thank you for your reply, the Gateway for the PC and the IPtables Machine are the same. as I told redirection is working fine if I try from another machine. but I am not abke to do the same from the IPtables machine using localhost or the IP it tells connection refused.

0.0.0.0 192.168.2.1 0.0.0.0 UG 100 0 0 eth0
My question was irrelevant, I was trying to replicate your setup but it had ipforwarding off. D'oh.

Have a look at this post http://www.linuxquestions.org/questi...-issue-487153/

In essence, you need the following

Code:
iptables -t nat -A OUTPUT -p tcp --dport 2200 -j DNAT --to 192.168.70.101
 
Old 03-29-2011, 12:03 AM   #5
pnmanojshenoy
Member
 
Registered: Jun 2008
Location: Cochin, India
Distribution: Debian,Ubuntu
Posts: 38

Original Poster
Rep: Reputation: 0
Hello,

I did check that before but was not working for me... but when I tried now it worked... had to flush Iptables two time, to get this worked..

iptables -t nat -F
iptables -F

Thank you.
 
  


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
iptables port forwarding packets Linux - Networking 14 06-10-2010 09:45 AM
Iptables - port forwarding to blocked port? spangberg Linux - Networking 2 03-26-2010 04:48 AM
Port forwarding using iptables just_me_then Linux - Networking 6 04-09-2008 06:29 AM
IPCHAINS port forwarding and IPTABLES port forwarding ediestajr Linux - Networking 26 01-14-2007 07:35 PM
Forwarding a port using iptables xtremeclones Linux - Networking 1 11-18-2006 05:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:09 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
Open Source Consulting | Domain Registration