I'm having problems configuring iptables rules on a double wan setup. The OS is Ubuntu 12.04 LTS.
I have 2 Wan connections, both with static IP. Wan-1 is on eth2, Wan-2 is on eth4. I want both of them to forward to the same internal servers.
Wan-1 rules are working, and I can access all internal servers without problem, but I can't access servers when using Wan-2.
Wan-1: (not the real IP addresses)
IP: 17.13.12.90
CIDR: 17.13.12.90/29
Netmask: 255.255.255.248
Gateway: 17.13.12.89
Wan-2: (not the real IP addresses)
IP: 17.13.12.174
CIDR: 17.13.12.174/29
Netmask: 255.255.255.248
Gateway: 17.13.12.169
Wan-1 (eth2) is the current default gateway, everything is working here. I can access internal servers from the internet. No problems. I can ping it from the outside and connect via SSH.
Wan-2 (eth4) is the new wan connection I'm setting up. I can ping it from the outside and connect via SSH to it. But I can't connect to internal servers from this IP.
Local network is eth0.
My /etc/iproute2/rt_tables file looks like this:
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
10 isp1
20 isp2
This are the ip rules I've setup:
ip route add 17.13.12.88 dev eth2 src 17.13.12.90 table isp1
ip route add default via 177.135.127.89 table isp1
ip route add 17.22.17.168 dev eth4 src 17.22.17.174 table isp2
ip route add default via 17.22.17.169 table isp2
ip route add 17.13.12.88 dev eth2 src 17.13.12.90
ip route add 17.22.17.168 dev eth4 src 17.22.17.174
ip route add default via 17.13.12.89
ip rule add from 17.13.12.90 table isp1
ip rule add from 17.22.17.174 table isp2
ip rule add fwmark 0x1 table isp1
ip rule add fwmark 0x2 table isp2
This is the iptables rules, concerning the mangle table:
$IPT -t mangle -A PREROUTING -p tcp -j CONNMARK --restore-mark
# Input rules
$IPT -t mangle -A INPUT -i $IF_ETH2 -p tcp -j MARK --set-mark 0xa
$IPT -t mangle -A INPUT -i $IF_ETH4 -p tcp -j MARK --set-mark 0xb
$IPT -t mangle -A PREROUTING -i $IF_ETH0 -m mark --mark 0xa -p tcp -j MARK --set-mark 0x1
$IPT -t mangle -A PREROUTING -i $IF_ETH0 -m mark --mark 0xb -p tcp -j MARK --set-mark 0x2
# output rules
$IPT -t mangle -A OUTPUT -m mark --mark 0xa -p tcp -j MARK --set-mark 0x1
$IPT -t mangle -A OUTPUT -m mark --mark 0xb -p tcp -j MARK --set-mark 0x2
Could someone please point me/help me out why aren't connexions coming from wan-2 being forward to the internal servers? The rules seem ok, but maybe I'm missing something.