LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 02-26-2013, 12:16 PM   #1
sanjay87
Member
 
Registered: Oct 2011
Posts: 164

Rep: Reputation: Disabled
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
 
Old 02-26-2013, 02:02 PM   #2
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (Chicago area)
Distribution: Red Hat (8.0, RHEL5,6), CentOS, SuSE (10.x, 11.x, 12.2, 13.2), Solaris (8-10), Tru64, MacOS, Raspian
Posts: 1,137

Rep: Reputation: 65
Quote:
Originally Posted by sanjay87 View Post
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
 
  


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
Port redirecting with IPtables tquang Linux - Networking 1 06-02-2012 04:34 PM
IPTABLES port redirecting to SQUID imoulas Linux - Server 1 07-12-2011 04:14 PM
[SOLVED] correct/safe iptables rules for redirecting port 80 to 8080 sundoe Linux - Security 3 07-13-2010 09:00 PM
redirecting a port on the same host with iptables nacio Linux - Networking 4 05-23-2008 02:15 PM
iptables port 80 rule Q doronunu Linux - Security 3 06-04-2006 07:55 PM

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

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