trimstray / iptables-essentials

Iptables Essentials: Common Firewall Rules and Commands.
MIT License
1.47k stars 267 forks source link

Being able to pass traffic through the wan in the table marked with a different source IP address. #11

Open samueljaydan opened 4 months ago

samueljaydan commented 4 months ago

There are 2 WAN interfaces.

WAN1 => fwmark 1 WAN2 => fwmark 2

lo998 has 2 different IP addresses. 127.0.88.1 will be used for WAN1, and 127.0.88.2 will be used for WAN2.

WAN1 => gateway => 1010.12.1 WAN1 => ip address => 10.10.12.254

WAN2 => gateway => 192.168.1.1 WAN2 => ip address => 192.168.1.3

When I run "ping -I 127.0.88.1 8.8.8.8", I want it to go through WAN1, and when I run "ping -I 127.0.88.2 8.8.8.8", I want it to go through WAN2. What should be the necessary iptables rules for this?

lo:998:0: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.88.1 netmask 255.255.255.255 loop txqueuelen 1000 (Local Loopback)

lo:998:1: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.88.2 netmask 255.255.255.255 loop txqueuelen 1000 (Local Loopback)