Hi,
We are running Centos 5. We recently added an additional broadband cable connection to one machine, which is both a Web server and a VoIP Telephony PBX. We want to have all the VoIP (SIP) traffic go through that connection (eth1). The web server on that same machine would continue to use the old, default connection (eth2). So, in short, the machine has 2 ethernet interfaces each connected to a different ISP connection.
I made a lot of research in order to have all the SIP traffic to our DID and termination provider go through the new connection (eth1). I gathered that I should use the iptables and ip commands for that. Here are the commands I tried, where %NEW_IP% is the new connection static IP address, %NEW_GATEWAY% is the IP address of the new connection gateway and %VOIP_PROVIDER% is the IP address of the VoIP SIP provider.
Code:
ip route flush table 1
ip route show table main | grep -Ev ^default \
| while read ROUTE ; do
ip route add table 1 $ROUTE
done
ip route add table 1 default via %NEW_GATEWAY%
ip rule add fwmark 1 table 1
ip route flush cache
iptables -t mangle -A PREROUTING -d %VOIP_PROVIDER% -j MARK --set-mark 1
iptables -t mangle -A PREROUTING -d %VOIP_PROVIDER% -j CONNMARK --save-mark
iptables -t nat -A POSTROUTING -o eth1 -j SNAT --to-source %NEW_IP%
So everything seems right to me there, but traceroute shows that the traffic is still routed through the old connection. Here is the traceroute dump where %OLD_GATEWAY% is the old connection's gateway (all other placeholders from previous code excerpt apply here) :
Code:
root@pbx:~ $ traceroute %VOIP_PROVIDER%
traceroute to %VOIP_PROVIDER%, 30 hops max, 40 byte packets
1 % OLD_GATEWAY% 0.940 ms 1.316 ms 1.580 ms
2 10.6.48.1 (10.6.48.1) 5.395 ms 8.302 ms 8.296 ms
3 10.170.161.22 (10.170.161.22) 8.305 ms 8.293 ms 8.338 ms
4 216.113.123.117 (216.113.123.117) 8.680 ms 8.672 ms 8.678 ms
5 216.113.123.18 (216.113.123.18) 8.672 ms 9.669 ms 9.695 ms
6 te6-1.cl-core04.vtl.mtl.iweb.com (207.253.238.114) 16.376 ms 12.805 ms 15.364 ms
7 %VOIP_PROVIDER% 15.752 ms 19.707 ms 23.030 ms
I was wondering if anyone ever attempted something similar. If so, is it possible to show me where I did wrong?
Thanks,
Vincent