LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Port redirection in Redhat Ent Linux5 (https://www.linuxquestions.org/questions/linux-networking-3/port-redirection-in-redhat-ent-linux5-700113/)

naw_deepak 01-27-2009 12:00 AM

Port redirection in Redhat Ent Linux5
 
Hi all,

I have a server on which nating is enabled. It has two ethernet eth0 and eth1. Eth0 is for external network and eth1 is for internal. My requirement is, the requests come from external network on port 21 should be redirected to port 10000. What is the iptable command should I use? or please guide me any way to make it possible.

Thanks in advance,
Deepak

rossonieri#1 01-27-2009 12:36 PM

hi,

Quote:

My requirement is, the requests come from external network on port 21 should be redirected to port 10000.
a little bit unclear,
there are 2 redirection mode in iptables :
using DNAT (can be in POSTROUTING & PREROUTING NAT table)
and or REDIRECT (just in PREROUTING NAT table).

so, to which NIC (external or internal) your external_port_21 traffic should be redirect?

DNAT :
iptables -t nat -I POSTROUTING -i external_NIC -p tcp --dport 21 -j DNAT --to-destination internal_server:port

REDIRECT :
iptables -t nat -I PREROUTING -i external_NIC -p tcp --dport 21 -j REDIRECT --to-port port

or $man iptables :)


All times are GMT -5. The time now is 10:22 AM.