通过Cisco 881 NAT的入站SIP呼叫几秒钟后挂断

我最近搬到了一个Cisco 881路由器来连接我的广域网。 我之前使用Cisco Linksys WAG320N作为我的调制解调器/路由器/ WiFi AP / NAT防火墙。 WAG320N现在运行在桥接模式,所以它只是一个调制解调器,它的一个局域网端口连接到思科881上的FE4 WAN

Cisco 881从我的ISP获得一个DHCP提供的IP。 我的LAN是默认Vlan 1(192.168.1.0/24)的一部分。 一般互联网连接工作很好,我设法为我的HTTP / HTTPS / SMTP /等设置静态NAT规则。 在我的局域网上运行的服务。 我不知道是否值得一提的是我select使用NVI NAT( ip nat enable而不是传统的ip nat outside / ip nat inside )设置。 我的理由是,NVI允许NAT从我的局域网环回到广域网IP,并返回到局域网上的必要服务器。

我在局域网上运行一个Asterisk 1.8集团电话,它连接到互联网上的一个SIP提供商。 通过旧的设置(WAG320N提供路由/ NAT)的入站和出站呼叫都正常工作。 但是,由于移动到思科881,入站呼叫约10秒后下降,而出站呼叫正常工作。

我的Asterisk PBX上logging以下消息:

 [Dec 9 15:27:45] WARNING[27734]: chan_sip.c:3641 retrans_pkt: Retransmission timeout reached on transmission [email protected] for seqno 1 (Critical Response) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions Packet timed out after 6528ms with no response [Dec 9 15:27:45] WARNING[27734]: chan_sip.c:3670 retrans_pkt: Hanging up call [email protected] - no reply to our critical packet (see https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions). 

(我知道这是一个相当普遍的问题 – 我花了两天的精力在Google上search)。

我按照我的说法完成了,并检查了https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions 。 参考上面链接的页面中的“其他SIP请求”部分,我认为由我的SIP提供商的ACK导致的连接不会通过NAT传回到我的PBX上的Asterisk。

我试图通过在881上的广域网接口上转储数据包来确定这一点。我设法从广域网接口中获取数据包的PCAP转储。 下面是路由器从我的提供商那里得到的一个ACK的例子:

 689 21.219999 193.xxx 188.xxx SIP 502 Request: ACK sip:[email protected] | 

但是Asterisk服务器上的SIP跟踪显示没有收到响应来自我的PBX的200 OK ACK

http://pastebin.com/wwHpLPPz

过去,我强烈build议禁用路由器和/或防火墙上的任何types的SIP ALG,并且在互联网上关于这个问题的许多post似乎支持这一点。 不过,我相信在Cisco IOS上,configuration命令禁用SIP ALG是no ip nat service sip udp port 5060但是这似乎并没有起到帮助的作用。 要确认configuration设置已设置:

 Router1#show running-config | include sip no ip nat service sip udp port 5060 

另一个有趣的转折:在短时间内,我尝试了另一个提供商。 幸运的是,我的试用版帐号仍然可用,所以在与我当前的提供商集成之前,我已将Asteriskconfiguration恢复为修订版。 然后我拨打与试用主干相关的DDI,呼叫没有挂断,我没有得到上面的错误! 对我来说,这指向提供商,但是我知道,就像所有提供商一样,会说:“我们的SIP代理没有问题 – 这是您的防火墙。” 我很想同意这一点,因为这个问题在旧的WAG320N路由器上做NAT时并不明显。

我相信你也会想看到我的running-config:

 ! ! Last configuration change at 15:55:07 UTC Sun Dec 9 2012 by xxx version 15.2 no service pad service tcp-keepalives-in service tcp-keepalives-out service timestamps debug datetime msec localtime show-timezone service timestamps log datetime msec localtime show-timezone no service password-encryption service sequence-numbers ! hostname Router1 ! boot-start-marker boot-end-marker ! ! security authentication failure rate 10 log security passwords min-length 6 logging buffered 4096 logging console critical enable secret 4 xxx ! aaa new-model ! ! aaa authentication login local_auth local ! ! ! ! ! aaa session-id common ! memory-size iomem 10 ! crypto pki trustpoint TP-self-signed-xxx enrollment selfsigned subject-name cn=IOS-Self-Signed-Certificate-xxx revocation-check none rsakeypair TP-self-signed-xxx ! ! crypto pki certificate chain TP-self-signed-xxx certificate self-signed 01 quit no ip source-route no ip gratuitous-arps ip auth-proxy max-login-attempts 5 ip admission max-login-attempts 5 ! ! ! ! ! no ip bootp server ip domain name dmz.merlin.local ip domain list dmz.merlin.local ip domain list merlin.local ip name-server xxxx ip inspect audit-trail ip inspect udp idle-time 1800 ip inspect dns-timeout 7 ip inspect tcp idle-time 14400 ip inspect name autosec_inspect ftp timeout 3600 ip inspect name autosec_inspect http timeout 3600 ip inspect name autosec_inspect rcmd timeout 3600 ip inspect name autosec_inspect realaudio timeout 3600 ip inspect name autosec_inspect smtp timeout 3600 ip inspect name autosec_inspect tftp timeout 30 ip inspect name autosec_inspect udp timeout 15 ip inspect name autosec_inspect tcp timeout 3600 ip cef login block-for 3 attempts 3 within 3 no ipv6 cef ! ! multilink bundle-name authenticated license udi pid CISCO881-SEC-K9 sn ! ! username xxx privilege 15 secret 4 xxx username xxx secret 4 xxx ! ! ! ! ! ip ssh time-out 60 ! ! ! ! ! ! ! ! ! interface FastEthernet0 no ip address ! interface FastEthernet1 no ip address ! interface FastEthernet2 no ip address ! interface FastEthernet3 switchport access vlan 2 no ip address ! interface FastEthernet4 ip address dhcp no ip redirects no ip unreachables no ip proxy-arp ip nat enable duplex auto speed auto ! interface Vlan1 ip address 192.168.1.1 255.255.255.0 no ip redirects no ip unreachables no ip proxy-arp ip nat enable ! interface Vlan2 ip address 192.168.0.2 255.255.255.0 ! ip forward-protocol nd ip http server ip http access-class 1 ip http authentication local ip http secure-server ip http timeout-policy idle 60 life 86400 requests 10000 ! ! no ip nat service sip udp port 5060 ip nat source list 1 interface FastEthernet4 overload ip nat source static tcp xxxx 80 interface FastEthernet4 80 ip nat source static tcp xxxx 443 interface FastEthernet4 443 ip nat source static tcp xxxx 25 interface FastEthernet4 25 ip nat source static tcp xxxx 587 interface FastEthernet4 587 ip nat source static tcp xxxx 143 interface FastEthernet4 143 ip nat source static tcp xxxx 993 interface FastEthernet4 993 ip nat source static tcp xxxx 1723 interface FastEthernet4 1723 ! ! logging trap debugging logging facility local2 access-list 1 permit 192.168.1.0 0.0.0.255 access-list 1 permit 192.168.0.0 0.0.0.255 no cdp run ! ! ! ! control-plane ! ! banner motd Authorized Access only ! line con 0 login authentication local_auth length 0 transport output all line aux 0 exec-timeout 15 0 login authentication local_auth transport output all line vty 0 1 access-class 1 in logging synchronous login authentication local_auth length 0 transport preferred none transport input telnet transport output all line vty 2 4 access-class 1 in login authentication local_auth length 0 transport input ssh transport output all ! ! end 

…如果它有任何用处,这里是我的Asterisk SIPconfiguration:

 [general] context=default ; Default context for calls allowoverlap=no ; Disable overlap dialing support. (Default is yes) udpbindaddr=0.0.0.0 ; IP address to bind UDP listen socket to (0.0.0.0 binds to all) ; Optionally add a port number, 192.168.1.1:5062 (default is port 5060) tcpenable=no ; Enable server for incoming TCP connections (default is no) tcpbindaddr=0.0.0.0 ; IP address for TCP server to bind to (0.0.0.0 binds to all interfaces) ; Optionally add a port number, 192.168.1.1:5062 (default is port 5060) srvlookup=yes ; Enable DNS SRV lookups on outbound calls ; Note: Asterisk only uses the first host ; in SRV records ; Disabling DNS SRV lookups disables the ; ability to place SIP calls based on domain ; names to some other SIP users on the Internet ; Specifying a port in a SIP peer definition or ; when dialing outbound calls will supress SRV ; lookups for that peer or call. directmedia=no ; Don't allow direct RTP media between extensions (doesn't work through NAT) externhost=<MY DYNDNS HOSTNAME> ; Our external hostname to resolve to IP and be used in NAT'ed packets localnet=192.168.1.0/24 ; Define our local network so we know which packets need NAT'ing qualify=yes ; Qualify peers by default dtmfmode=rfc2833 ; Set the default DTMF mode disallow=all ; Disallow all codecs by default allow=ulaw ; Allow G.711 u-law allow=alaw ; Allow G.711 a-law ; ---------------------- ; SIP Trunk Registration ; ---------------------- ; Orbtalk register => <MY SIP PROVIDER USER NAME>:[email protected]/<MY DDI> ; Main Orbtalk number ; ---------- ; Trunks ; ---------- [orbtalk] ; Main Orbtalk trunk type=peer insecure=invite host=sipgw3.orbtalk.co.uk nat=yes username=<MY SIP PROVIDER USER NAME> defaultuser=<MY SIP PROVIDER USER NAME> fromuser=<MY SIP PROVIDER USER NAME> secret=xxx context=inbound 

我真的不知道该去哪里。 如果有人能帮我弄清楚为什么这些电话被拒绝了,我将不胜感激。 请让我知道是否需要进一步的信息。

更新10/12/2012(1)

@GerryEganbuild议我添加以下静态NAT: ip nat source static udp 192.168.1.2 5060 interface FastEthernet 4 5060虽然这似乎解决了事情,据我所知,这将使我打开暴力攻击5060。

@GerryEgan还提出了一个检查规则: ip inspect name autosec_inspect sip …和(config-if)#ip inspect autosec_inspect in我的广域网接口上的(config-if)#ip inspect autosec_inspect in即使在清除了NAT NVI转换后,这也不能解决问题。

这是一个debug ip nat sip从一个入站呼叫被丢弃: http : //pastebin.com/3WHPcyDD

注意:如果我尝试上面提到的no ip nat service sip udp port 5060configuration设置,我没有从debug ip nat sip得到任何debugging输出,所以现在我的默认ip nat service sip udp port 5060在我的configuration – 希望我不会混淆事情。

为了使情况变得更糟,我的静态NAT NVI规则似乎在重新加载路由器时变得混乱:-(这是一个单独的问题,但是可能会对您的响应产生影响。

更新10/12/2012(2) :当呼叫被Asterisk挂起时,我在/var/log/syslog看到以下内容:

 Dec 10 20:02:39 <PBX> asterisk[26620]: rc_avpair_new: unknown attribute 1490026597 

更新11/12/2012

@GerryEganbuild议增加:

 access-list 101 permit udp XXXX 0.0.0.255 host 1.2.3.4 eq 5060 access-list 101 deny udp any any eq 5060 access-list 101 permit ip any any 

 interface FastEthernet4 ip access-group 101 in 

我可以看到理论,所以我期待这个工作,但不幸的是不是。

这是奇怪的,因为我以前的WAG320N处理SIP到相同的供应商,PBX等没有configuration或NAT'ing要求。 这促使我重build新的881,所以为了完整性,这是当前的configuration:

 ! ! Last configuration change at 20:20:15 UTC Tue Dec 11 2012 by xxx version 15.2 no service pad service timestamps debug datetime msec service timestamps log datetime msec service password-encryption ! hostname xxx ! boot-start-marker boot-end-marker ! ! enable secret 4 xxxx ! aaa new-model ! ! aaa authentication login local_auth local ! ! ! ! ! aaa session-id common ! memory-size iomem 10 ! crypto pki trustpoint TP-self-signed-xxx enrollment selfsigned subject-name cn=IOS-Self-Signed-Certificate-xxx revocation-check none rsakeypair TP-self-signed-xxx ! ! crypto pki certificate chain TP-self-signed-xxx certificate self-signed 01 xxx quit ip gratuitous-arps ip auth-proxy max-login-attempts 5 ip admission max-login-attempts 5 ! ! ! ! ! ip domain list dmz.xxx.local ip domain list xxx.local ip domain name dmz.xxx.local ip name-server 192.168.1.x ip cef login block-for 3 attempts 3 within 3 no ipv6 cef ! ! multilink bundle-name authenticated license udi pid CISCO881-SEC-K9 sn xxx ! ! username admin privilege 15 secret 4 xxx username joe secret 4 xxx ! ! ! ! ! ip ssh time-out 60 ! ! ! ! ! ! ! ! ! interface FastEthernet0 no ip address ! interface FastEthernet1 no ip address ! interface FastEthernet2 no ip address ! interface FastEthernet3 switchport access vlan 2 no ip address ! interface FastEthernet4 ip address dhcp ip access-group 101 in ip nat enable duplex auto speed auto ! interface Vlan1 ip address 192.168.1.x 255.255.255.0 no ip redirects no ip unreachables no ip proxy-arp ip nat enable ! interface Vlan2 ip address 192.168.0.x 255.255.255.0 ! ip forward-protocol nd ip http server ip http access-class 1 ip http authentication local ip http secure-server ! ! ip nat source list 1 interface FastEthernet4 overload ip nat source list 2 interface FastEthernet4 overload ip nat source static tcp 192.168.1.x 1723 interface FastEthernet4 1723 ! ! access-list 1 permit 192.168.0.0 0.0.0.255 access-list 2 permit 192.168.1.0 0.0.0.255 access-list 101 permit udp 193.xx0 0.0.0.255 any eq 5060 access-list 101 deny udp any any eq 5060 access-list 101 permit ip any any ! ! ! ! control-plane ! ! banner motd Authorized Access only ! line con 0 exec-timeout 15 0 login authentication local_auth line aux 0 exec-timeout 15 0 login authentication local_auth line vty 0 4 access-class 2 in login authentication local_auth length 0 transport input all ! ! end 

你会注意到我使用了access-list 101 permit udp 193.xx0 0.0.0.255 any eq 5060代替access-list 101 permit udp XXXX 0.0.0.255 host 1.2.3.4 eq 5060 。 原因是,我的WAN IP是由DHCP提供的,所以我没有设置IP进入host 。 我希望这是一个有效的替代品(?)。

再次重申,这个SIP提供者在我的老家“Linksys WAG320N上完美工作,没有configurationNAT,防火墙。 该系统默认禁用SIP ALG。

另一个兴趣点 – 我无法通过此路由器NAT PPTP入站此刻。 看起来GREstream量没有通过。 虽然我知道两者不一样,但它可能是相同的底层configuration问题,阻止路由器NAT正确的每个协议的stream量 – 我可能会咆哮错误的树…

更新16/12/2012

在Asterisk的sip.conf中注释掉localnet=192.168.1.0/24时,我看到了一个改进; 当省略此设置时,我可以接听来电,而不会挂断电话。

我知道这可以被看作是解决这个问题的方法,但这并不能解释为什么当PBX作为防火墙/路由器坐在WAG320N的后面时,为什么PBX使用这个设置大约6个月。 考虑到这一点,有没有人有更多的想法? 注释掉localnet指令并不是在我的脑海里,我不愿意把它作为一个永久的解决scheme,当它和旧的路由器一起工作的时候。

我已经看到了多个881的问题,我已经部署了nat超载和使用接口。 在大多数情况下,使链接静态IP和更改IP NAT超载命令已经解决了调用,甚至手机冻结的大部分问题。 祝你好运

如果添加NAT和检查规则解决了问题,但不想打开端口到互联网,为什么不向WAN端口添加访问列表,以便只允许来自SIP提供商的端口5060上的stream量IP地址范围? 你需要像这样的东西:

 access-list 101 permit udp XXXX 0.0.0.255 host 1.2.3.4 eq 5060 access-list 101 deny udp any any eq 5060 access-list 101 permit ip any any 

XXXX / 24是您的SIP提供商范围,1.2.3.4是您的外部IP。 然后将其应用于您的外部接口:

 interface FastEthernet4 ip access-group 101 in 

我不知道从你的更新,如果NAT规则完全解决它,你已经删除它,以使其工作的另一种方式,或者如果它仍然不符合NAT规则…如果NAT修复它,添加访问列表你应该很好。 如果还有更多的问题,请告诉我。

我已经有同样的问题,整个一个月之间跳跃我有两个VPS,一个是动力,但完美的作品,另一个是超能力和遭受同样的问题。 在没有回答的情况下到互联网上,我不得不继续testing,直到发现问题。 我通过FreePBX高级设置设置“qualify = no”,之后一切开始工作。

唯一的罪魁祸首是Qualify。