LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   forwarding traffic on iptables redhat 6 (https://www.linuxquestions.org/questions/linux-networking-3/forwarding-traffic-on-iptables-redhat-6-a-4175591813/)

bsystem 10-20-2016 05:02 AM

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

lazydog 10-20-2016 11:25 AM

[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


All times are GMT -5. The time now is 01:35 AM.