更改路由后,SIP 服务器无法访问。我有 2 个 ISP,ISP 1 是我的默认 ISP,ISP 2 是我的备用 ISP。我在 Linux 路由器 Linux 后面有一个拨号器。Linux 路由器有 3 个以太网卡。
路由器网络配置
root@intellipatient:~# ifconfig -a
eth0 Link encap:Ethernet HWaddr 64:66:b3:02:d9:5a
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::6666:b3ff:fe02:d95a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:10209371 errors:0 dropped:0 overruns:0 frame:0
TX packets:7782687 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2896210016 (2.8 GB) TX bytes:1014989041 (1.0 GB)
Interrupt:20 Base address:0xa000
eth1 Link encap:Ethernet HWaddr d8:50:e6:51:1b:5c
inet addr:121.96.56.5 Bcast:121.96.56.63 Mask:255.255.255.192
inet6 addr: fe80::da50:e6ff:fe51:1b5c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1088495 errors:0 dropped:7954 overruns:0 frame:0
TX packets:346384 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:83277286 (83.2 MB) TX bytes:86874892 (86.8 MB)
Interrupt:42 Base address:0xe000
eth2 Link encap:Ethernet HWaddr c0:4a:00:04:04:ec
inet addr:192.168.254.1 Bcast:192.168.254.255 Mask:255.255.255.0
inet6 addr: fe80::c24a:ff:fe04:4ec/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7250634 errors:0 dropped:0 overruns:0 frame:0
TX packets:9369485 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1001062387 (1.0 GB) TX bytes:2798746300 (2.7 GB)
Interrupt:41 Base address:0xc000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:44550 errors:0 dropped:0 overruns:0 frame:0
TX packets:44550 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:4021256 (4.0 MB) TX bytes:4021256 (4.0 MB)
这里是路由器中设置的当前路由,我现在将默认路由器设置为全球 ISP 提供商
root@intellipatient:~# ip route show
default via 192.168.254.254 dev eth2
121.96.56.0 dev eth1 scope link src 121.96.56.5
121.96.56.0/26 dev eth1 scope link src 121.96.56.5
169.254.0.0/16 dev eth0 scope link
192.168.1.0/24 dev eth0 scope link src 192.168.1.1
192.168.254.0 dev eth2 scope link src 192.168.254.1
192.168.254.0/24 dev eth2 scope link src 192.168.254.1
这是防火墙配置
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -A FORWARD -j ACCEPT
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -m limit --limit 5/min -j LOG --log-prefix forwarding --log-level 7
iptables -A FORWARD -j DROP
iptables -t nat -A POSTROUTING -o eth1 -j SNAT --to-source 121.96.56.5
iptables -t nat -A POSTROUTING -o eth2 -j SNAT --to-source 192.168.254.1
我还为拨号器创建了表拨号器,用于分割访问,目前设置为 bayantel ISP
root@intellipatient:~# ip route show table dialer
default via 121.96.56.1 dev eth1
IPtables 规则
root@intellipatient:~# ip rule ls
0: from all lookup local
32762: from 192.168.1.2 lookup dialerbk
32763: from 192.168.1.20 lookup dialer
32764: from 192.168.254.1 lookup globetel
32765: from 121.96.56.5 lookup bayantel
32766: from all lookup main
32767: from all lookup default
问题是,当我将拨号器路由设置为 bayantel 时
my dialer show
2001/2001 (Unspecified) D N 0 UNKNOWN
2000/2000 (Unspecified) D N 0 UNKNOWN
APN 208.74.75.250 N 5060 UNREACHABLE
apn 208.74.75.250 N 5060 UNKNOWN
25 sip peers [Monitored: 1 online, 24 offline Unmonitored: 0 online, 0 offline]
goautodial*CLI>
然后当我将拨号器的路线改为地球仪
ip route change default via 192.168.254.254
然后我的拨号器再次连接到 voip 提供商。
答案1
简单的设置如下:
- 在
sip.conf
设置中bind=192.168.254.1 - 通过 eth2 向您的 voip 提供商添加路由
所有其他设置都需要检查数据包的实际传输方式以及 Aterisk 在 SIP 数据包中发送的内容。您无法在 Stackoverflow 格式中找到答案。