LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 10-20-2016, 05:02 AM   #1
bsystem
LQ Newbie
 
Registered: Oct 2016
Location: Paris
Distribution: Redhat/debian and AIX
Posts: 3

Rep: Reputation: Disabled
Exclamation forwarding traffic on iptables redhat 6


Hello
I have redhat 6.7 with iptables 1.4.7

Here are the two rules I want to make:

1-forward all incoming traffic by eht0 to eth1 (all protocols)
2-forward all incoming traffic by eth1 to another ip server (all protocols)

Here are the two rules I have defined:

1-iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
2-iptables -t nat -A PREROUTING -p tcp -d x.x.x.x -j DNAT --to y.y.y.y
(x.x.x.x is the ip of eth1)

Only the first pass,and when I put “iptables –S”, it is visible, the other not
The second disappears once the server rebooted.

I checked all these elements

1-CONFIG_IP_NF_TARGET_REDIRECT=m
2-CONFIG_NETFILTER_XT_MATCH_STATE=m
3-net.ipv4.ip_forward = 1

Could you help me
Thanks in advance
 
Old 10-20-2016, 11:25 AM   #2
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
[QUOTE=bsystem;5620469]
Here are the two rules I want to make:

1-forward all incoming traffic by eht0 to eth1 (all protocols)
2-forward all incoming traffic by eth1 to another ip server (all protocols)
[quote]

If you are forwarding everything regardless of port or protocol then all you need is:
Code:
iptables -A FORWARD -j ACCEPT
Quote:
Here are the two rules I have defined:

1-iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
2-iptables -t nat -A PREROUTING -p tcp -d x.x.x.x -j DNAT --to y.y.y.y
(x.x.x.x is the ip of eth1)
Not sure why you need the DNAT rule here could you explain this in more detail like what you are trying to accomplish?

Quote:
Only the first pass,and when I put “iptables –S”, it is visible, the other not
One is a nat filter rule and only shows up when you list the nat rules.

Quote:
The second disappears once the server rebooted.
That is because you need to save your rules before you reboot if you do not have that already setup in iptables-config
 
  


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
ip forwarding with iptables - double forwarding with openVPN?? sousacanfly Linux - Networking 8 01-20-2014 08:49 AM
[SOLVED] RedHat 6 iptables port forwarding mappster Red Hat 1 10-11-2012 10:45 AM
[HELP] redirect traffic to spesific port based on Traffic Content using iptables summersgone Linux - Server 2 06-22-2009 11:26 AM
iptables firewall forwarding L2TP traffic to windows 2003 server access_denied79 Linux - Networking 1 06-07-2007 09:52 PM
port 25 forwarding iptables FC4, can't get it to pass traffic sahib2u Linux - Security 4 03-01-2006 10:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:43 PM.

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