0

I have a router (with iptables support) with 2 WAN interfaces (wan0 and wan1) and I am trying to redirect calls of specific IPs (for ex: 8.8.8.8) over second interface (wan1) using ip tables. Traffic is coming from single LAN interface (eth0). I tried to mark the network packets like this:

iptables -t mangle -I PREROUTING -d $PUBLIC_IP -p tcp --dports 80,443 -j MARK --set-mark 0x77

and then create a rule through UI of router based on markings. But no luck.

Can this be done using only iptables?

I am sorry I am not coming from networking field so any help appreciate.

Thanks in advance!

1 Answer 1

0

It sounds like you want to create a DNAT rule. Maybe something like:

iptables -t nat -A PREROUTING \ -d $ORIGINAL_IP \ -p tcp --dports 80,443 \ -j DNAT --to-destination $NEW_IP 
1
  • I solved my problem using static routes, but interested in DNAT rule you provided. So, this rule will forward complete traffic from ORIGINAL_IP to NEW_IP? This implies that the WAN IP is known? Commented Jul 11, 2023 at 9:27

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.