LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 10-11-2012, 04:12 AM   #1
mappster
LQ Newbie
 
Registered: Oct 2012
Posts: 2

Rep: Reputation: Disabled
RedHat 6 iptables port forwarding


Hi,

I am trying to use iptables on RHEL6 to forward requests on port 4443 to 443 for specific nics.

The reason - there is a feature in haproxy load balancer that allows you to have a check port different to the port you want to send to, this allows a server to stop receiving traffic without restarting haproxy.

I have had this working on RHEL5 on a single nic, but the same commands don't work on 6. SELinux is disabled, there are no other iptables rules.

The lines I used to use are:

/sbin/iptables -t nat -A OUTPUT -p tcp --dport 4443 -j REDIRECT --to-port 443
/sbin/iptables -t nat -A PREROUTING -p tcp --dport 4443 -j REDIRECT --to-port 443

Also -

With a single nic/ip address this works as expected, but with virtual nics and extra ip addresses it doesn't.

Many Thanks

Jon

Last edited by mappster; 10-11-2012 at 05:12 AM.
 
Old 10-11-2012, 10:45 AM   #2
mappster
LQ Newbie
 
Registered: Oct 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
Solved

I persevered with this and got it to work.

The commands are to forward the ports:-

iptables -t nat -A PREROUTING -i bond0 -p tcp -d 192.168.100.160 --dport 4443 -j DNAT --to 192.168.100.160:443
iptables -t nat -A PREROUTING -i bond0 -p tcp -d 192.168.100.161 --dport 4443 -j DNAT --to 192.168.100.161:443
iptables -t nat -A PREROUTING -i bond0 -p tcp -d 192.168.100.162 --dport 4443 -j DNAT --to 192.168.100.162:443

etc.

And to stop the forwarding:-

iptables -t nat -D PREROUTING -i bond0 -p tcp -d 192.168.100.160 --dport 4443 -j DNAT --to 192.168.100.160:443
iptables -t nat -D PREROUTING -i bond0 -p tcp -d 192.168.100.161 --dport 4443 -j DNAT --to 192.168.100.161:443
iptables -t nat -D PREROUTING -i bond0 -p tcp -d 192.168.100.162 --dport 4443 -j DNAT --to 192.168.100.162:443
 
  


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
Iptables Port forwarding pnmanojshenoy Linux - Networking 4 03-29-2011 12:03 AM
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
IPCHAINS port forwarding and IPTABLES port forwarding ediestajr Linux - Networking 26 01-14-2007 07:35 PM
iptables and port forwarding cs.cracker Linux - Networking 5 09-02-2006 01:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

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