I have a issabel Linux (based on Centos 7) with 3 ethernet, and I want this scenario:
eth0 with IP 172.16.3.30/16 ----gw(172.16.0.1)----> (I want to use as Default Gateway)
eth1 with IP 10.1.5.102/30 -----gw(10.1.5.101)----> (mark connections to 10.10.10.10:5160 for send via 10.1.5.101 with own src(10.1.5.102))
eth2 with IP 10.1.5.106/30 -----gw(10.1.5.105)----> (mark connections to 10.10.10.10:5161 for send via 10.1.5.101 with own src(10.1.5.106))
attention : there is one same destination address! (10.10.10.10 but different port)
I am using this codes:
iptables -A OUTPUT -t mangle -p udp -d 10.10.10.10/32 --dport 5160 -j MARK --set-mark 1
iptables -A OUTPUT -t mangle -p udp -d 10.10.10.10/32 --dport 5161 -j MARK --set-mark 2
echo 100 sip102 >> /etc/iproute2/rt_tables
echo 101 sip106 >> /etc/iproute2/rt_tables
ip route add default dev eth1 table sip102
ip route add default dev eth2 table sip106
ip rule add from all fwmark 1 table sip102
ip rule add from all fwmark 2 table sip106
But SIP Trunks cannot be connect. (I was changed first two line to -A PREROUTING but not effected)
When I am trying to test table's route without marking with this:
ip rule add to 10.10.10.10 table sip102
I see one SIP trunk is connected (10.1.5.102 > 10.10.10.10:5160 Connected)