routing for a multihomed network 
Linux connected via two networkcards to two different providers.

You coud use source based routing or if you prefere to route some ports only to on provider
here is my solution. Usefull for a private VOIP-Provider having two links and uses one link for RTP and the other for SIP.

RTP_IF="eth0"
RTP_GW_IP="10.0.1.1"

iptables -F -t mangle

# mark incomming unmarked connection
iptables -t mangle -A PREROUTING -i $RTP_IF -m connmark ! --mark 1 -j CONNMARK --set-mark 0x1


# This is the most important rule for marked incomming and marked outgoing connections to set packet MARK for routing
iptables -t mangle -A OUTPUT -m connmark --mark 1 -j CONNMARK --restore-mark
iptables -t mangle -A OUTPUT -m mark --mark 0x1 -j ACCEPT


# mark outgoing connection and packet (my RTP Ports)
iptables -t mangle -A OUTPUT -p udp --sport 5000:5058 -m connmark ! --mark 1 -j CONNMARK --set-mark 0x1
iptables -t mangle -A OUTPUT -p udp --sport 5000:5058 -m connmark --mark 1 -j MARK --set-mark 0x1


ip route flush table 1
ip route add default dev $RTP_IF via $RTP_GW_IP table 1
ip rule del fwmark 1 table 1
ip rule add fwmark 1 table 1
ip route flush cache


[ view entry ] ( 927 views )   |  print article

<<First <Back | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | Next> Last>>