Имеется шлюз с debian 6. На него заведены 2 провайдера. Один подключен через ethernet, второй через pppoe. В 101 vlan за этим шлюзом имеется сервер asterisk. Он регистрируется на sip-сервере второго провайдера. В /etc/iproute2/rt_tables добавлены две таблицы, через которые осуществляется маршрутизация. В /etc/ppp/ip-up.d кинут скрипт
#!/bin/sh
IF0=eth0
IF1=eth1
IF_PPP=ppp0
IF_VLAN101=eth3.101
IP0=192.168.0.254
IP1=1.1.1.1
IP_PPP=2.2.2.2
IP_VLAN101=192.168.101.254
P1=1.1.1.254
P_PPP=2.2.2.254
P0_NET=192.168.0.0/24
P1_NET=1.1.1.128/25
P_PPP_NET=2.2.2.254/32
P101_NET=192.168.101.0/24
ip route flush table ER
ip route flush table RT
ip route add $P1_NET dev $IF1 src $IP1 table ER
ip route add default via $P1 table ER
ip route add $P_PPP_NET dev $IF_PPP src $IP_PPP table RT
ip route add default via $P_PPP table RT
ip route add $P1_NET dev $IF1 src $IP1
ip route add $P_PPP_NET dev $IF_PPP src $IP_PPP
ip rule flush
ip rule add from all pref 32766 table main
ip rule add from all pref 32767 table default
ip rule add from $IP1 table ER
ip rule add from $IP_PPP table RT
ip rule add to 89.239.131.7 table RT
ip rule add to 89.239.139.130 table RT
ip rule add to 89.239.139.131 table RT
ip route flush cache
exit 0
[Nov 2 04:04:41] NOTICE[2736]: chan_sip.c:11569 sip_reg_timeout: -- Registration for 'XXXXXX@89.239.131.7' timed out, trying again (Attempt #53)
# tcpdump -ni ppp0
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ppp0, link-type LINUX_SLL (Linux cooked), capture size 65535 bytes
03:51:46.629510 IP 1.1.1.1.5060 > 89.239.131.7.5060: SIP, length: 545
03:51:46.660514 IP 1.1.1.1.5060 > 89.239.131.7.5060: SIP, length: 545
03:51:46.829653 IP 1.1.1.1.5060 > 89.239.131.7.5060: SIP, length: 501
03:51:47.244664 IP 1.1.1.1.5060 > 89.239.131.7.5060: SIP, length: 545
03:51:47.343674 IP 1.1.1.1.5060 > 89.239.131.7.5060: SIP, length: 545
03:51:47.828657 IP 1.1.1.1.5060 > 89.239.131.7.5060: SIP, length: 501
03:51:47.996670 IP 1.1.1.1.5060 > 89.239.131.7.5060: SIP, length: 545
^C
7 packets captured
7 packets received by filter
0 packets dropped by kernel
$ ping -c4 89.239.131.7
PING 89.239.131.7 (89.239.131.7) 56(84) bytes of data.
64 bytes from 89.239.131.7: icmp_seq=1 ttl=251 time=6.03 ms
64 bytes from 89.239.131.7: icmp_seq=2 ttl=251 time=5.03 ms
64 bytes from 89.239.131.7: icmp_seq=3 ttl=251 time=8.09 ms
64 bytes from 89.239.131.7: icmp_seq=4 ttl=251 time=7.09 ms
--- 89.239.131.7 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 5.034/6.564/8.091/1.148 ms
# tcpdump -ni ppp0 icmp
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ppp0, link-type LINUX_SLL (Linux cooked), capture size 65535 bytes
03:56:10.409096 IP 2.2.2.2 > 89.239.131.7: ICMP echo request, id 16168, seq 1, length 64
03:56:10.414895 IP 89.239.131.7 > 2.2.2.2: ICMP echo reply, id 16168, seq 1, length 64
03:56:11.410039 IP 2.2.2.2 > 89.239.131.7: ICMP echo request, id 16168, seq 2, length 64
03:56:11.414896 IP 89.239.131.7 > 2.2.2.2: ICMP echo reply, id 16168, seq 2, length 64
03:56:12.410988 IP 2.2.2.2 > 89.239.131.7: ICMP echo request, id 16168, seq 3, length 64
03:56:12.418895 IP 89.239.131.7 > 2.2.2.2: ICMP echo reply, id 16168, seq 3, length 64
03:56:13.411984 IP 2.2.2.2 > 89.239.131.7: ICMP echo request, id 16168, seq 4, length 64
03:56:13.418898 IP 89.239.131.7 > 2.2.2.2: ICMP echo reply, id 16168, seq 4, length 64