LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need help on iptables Port redirecting rule (https://www.linuxquestions.org/questions/linux-newbie-8/need-help-on-iptables-port-redirecting-rule-4175451780/)

sanjay87 02-26-2013 11:16 AM

Need help on iptables Port redirecting rule
 
Hi


Need help how can i redirect the incoming traffic 8080 443 of server example.com to port 8080 of xxx.com.I tried out below rule but not seems to be working

iptables -t nat -I PREROUTING --src example.com --dst xxx.com -p tcp --dport 8080

Need help how can i redirect traffic via iptables

rnturn 02-26-2013 01:02 PM

Quote:

Originally Posted by sanjay87 (Post 4900192)
Need help how can i redirect the incoming traffic 8080 443 of server example.com to port 8080 of xxx.com.I tried out below rule but not seems to be working

iptables -t nat -I PREROUTING --src example.com --dst xxx.com -p tcp --dport 8080

Need help how can i redirect traffic via iptables

I use lines like the one below to redirect inbound Web traffic to a set of aliases on the "dirty" side of the firewall to specific boxes on the "clean" side:
Code:

iptables --table nat --append PREROUTING --in-interface ${EXTERNAL_IF} \
--destination ${EXTERNAL_IPADDR} --source 0/0 --protocol tcp \
--destination-port 80 --jump DNAT --to-destination ${INTERNAL_IP}:80

If you need to redirect traffic intended for two ports (8080 & 443) you might need two lines; I'm not certain if you could specify a comma-delimited list of ports in a single command line. Note: The shell variables would, obviously, need to be set to whatever is appropriate for your network and the port numbers would need to be changed as well. Plus... it's been years since I wrote that Iptables rule so I'm not sure if all of those options are needed for your situation. You could comment out your line and add the one above (after tweaking) and see if that solves your problem.

Hope this helped...

--
Rick


All times are GMT -5. The time now is 12:54 AM.