LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 02-26-2013, 11:16 AM   #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, 01:02 PM   #2
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
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



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

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

All times are GMT -5. The time now is 03:02 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