中国电信SIP账号在FreePBX 13中的中继设置

在《配置EPON家庭网关接入中国电信电话交换IP网络》一文中我们介绍了如何使用MicroSIP软电话程序接入中国电信的电话IP网络,并提出了实现局域网电话软交换(IP-PBX)的可能性。以下FreePBX 13的中继设置已经通过几周的实际测试,可以放心使用。

在FreePBX 13管理界面上,创建类型为chan_pjsip的SIP中继(Trunk),并在中继编辑页面的“pjsip Settings”选项卡里输入如下参数:

General:
  Username: +8621XXXXXXXX@sh.ctcims.cn
  Secret: <SECRET>
  SIP Server: sh.ctcims.cn
  SIP Server Port: 5060

Advanced:
  From Domain: sh.ctcims.cn
  From User: +8621XXXXXXXX
  Client URI: sip:+8621XXXXXXXX@sh.ctcims.cn:5060
  AOR Contact: sip:+8621XXXXXXXX@sh.ctcims.cn:5060
  Match(Permit): 15.192.0.0/16

Codecs: Enable g729

注:Match(Permit)为所有局端SIP服务器可能所在的网段。

由于电信IP电话网络的DNS服务器中没有sh.ctcims.cn这个记录,并且目前FreePBX 13中chan_pjsip的Outbound Proxy设置无效,我们必须在本地DNS服务器中为sh.ctcims.cn设置解析。在常见的DNS代理程序dnsmasq中,设置参数如下:

server=/sh.ctcims.cn/15.192.252.188
address=/sh.ctcims.cn/15.192.60.71

其中,server是EPON网关的VOICE_INTERNET连接(epon0.4)获得的DNS服务器之一,address为sh.ctcims.cn作本地解析(EPON网关中预置的OutboundProxy域名解析出来的两个IP地址之一)。

14 comments

  • fow__who

    博主,你好。我坐标在020广州,按照你写的方法,目前卡在FreePBX 13的配置上,或多或少的研究了2个礼拜,依然一无所获。
    我根据你前文的一篇–《配置EPON家庭网关接入中国电信电话交换IP网络》中,尝试用microsip已经可以呼出呼入成功。
    唯独剩下这个freepbx 13做中继的配置,毫无头绪,还望博主能看到我的评论,不吝赐教!!

    • wenzhuo

      祝贺你,如果MicroSIP能调通,FreePBX应该也一定可以的;加油!呵呵
      我核对了一下配置,我可能漏记一个关键参数:Edit Trunk / pjsip Settings / Advanced / Match (Permit),把它设为局端所有SIP服务器可能所在的CIDR网段(/16应该就可以了);还有一个Qualify Frequency参数,现在我不清楚它缺省值是多少秒,建议改到60以下。

  • fox__who

    很高兴那么快能看到博主的回复!
    freepbx13要我填呼出的拨号规则,这个我真心不会,还望可以指点一二!

    • wenzhuo

      估计你现在只有一个中继,拨号规则很简单啊,一个点号”.”就可以了。读读freepbx的文档吧

  • fox__who

    博主你好,请忽略那条评论,是我错误输入了URI内容。
    我修正后,我按照你的设置指引进行设置,目前日志上提示
    [2017-05-02 01:11:57] VERBOSE[6255] res_pjsip/pjsip_configuration.c: Contact test/sip:+862037612170@gd.ctcims.cn:5060 is now Unreachable. RTT: 0.000 msec
    以上错误,请问如何调通??

    • wenzhuo

      dns问题解决了吗?gd.ctcims.cn是否可解析?

      • fox__who

        不知道这样是否算搞定了,我这边电信的SIP代理服务器是bac01.gz.gd.ctcims.cn,这个域名可以正常被解析。
        而gd.ctcims.cn则无法解析,我尝试过,无论在公网下,还是在VOIP专网下(用VOIP专网下的DNS为192.168.200.1去进行解析),也无法解析此域名。因此我在openwrt的DNSMASQ里面强制将gd.ctcims.cn的IP解析为bac01.gz.gd.ctcims.cn的IP。
        IP为219.137.176.128,不知道这样是否正确。
        博主,未知是否可以方便留下即时通讯的方式?? 我目前搞不定freepbx13的设定,已经搞得头都大了

        • wenzhuo

          两地电信网络结构未必相同,我们的局域网结构也不一样,问题比较复杂,我自己也是琢磨了好久历时一个多星期搞定的,恕不能提供即时技术支持。不过,根据你已提供的信息,如果你多花时间调试,肯定可以在freepbx里连通的。建议你在freepbx或openwrt路由器中抓包分析一下。这几天有时间我倒是可以重新创建Trunk核对一遍本文里的中继设置信息,以确保至少在上海电信范围内信息完整无误。不过,基本上就这些配置信息了。现在我用两个Cisco 7911话机作为分机,效果很好。

          其他具体设置,如分机设置、拨号规则,你还得多读freepbx文档,或者向freepbx社区咨询。

          • wenzhuo

            对配置作了如下变更:
            1. 去掉Contact User
            2. 增加Match(Permit)网段
            3. 增加g729 codec

            已通过重建trunk确认设置完整无误。

        • wenzhuo

          上海电信话音网络跟Internet隔离开的,分配的竟然是惠普公司IP地址段15.0.0.0/8。既然MicroSIP已经能注册上219.137.176.128,你只需在freepbx里作个DNS查询,确认gd.ctcims.cn解析到219.137.176.128,DNS解析及网络连通性上应该就没有问题了。

          • fox__who

            非常感谢博主的新编辑的指引操作,我已经按照你的指引配置好并成功使用了! 非常感谢博主!

  • fox__who

    我粘贴一段microsip的日志,看看是否有助于分析问题

    10:32:44.813 sip_endpoint.c .Module “mod-pjsua-log” registered
    10:32:44.813 sip_endpoint.c .Module “mod-tsx-layer” registered
    10:32:44.813 sip_endpoint.c .Module “mod-stateful-util” registered
    10:32:44.813 sip_endpoint.c .Module “mod-ua” registered
    10:32:44.813 sip_endpoint.c .Module “mod-100rel” registered
    10:32:44.813 sip_endpoint.c .Module “mod-pjsua” registered
    10:32:44.813 sip_endpoint.c .Module “mod-invite” registered
    10:32:44.816 wmme_dev.c ..WMME found 3 devices:
    10:32:44.816 wmme_dev.c .. dev_id 0: Wave mapper (in=2, out=2)
    10:32:44.816 wmme_dev.c .. dev_id 1: 麦克风 (Realtek High Definition (in=2, out=0)
    10:32:44.816 wmme_dev.c .. dev_id 2: Skyworth UHD-4 (2- NVIDIA High (in=0, out=2)
    10:32:44.816 wmme_dev.c ..WMME initialized
    10:32:44.816 pjlib ..select() I/O Queue created (0154E874)
    10:32:44.816 silk.c ..Init silk
    10:32:44.816 silk.c ..Init silk > DONE
    10:32:44.816 silk.c ..silk enum codecs
    10:32:44.816 silk.c ..silk add codecs
    10:32:44.816 silk.c ..Add codec 24000
    10:32:44.816 silk.c ..silk add codecs
    10:32:44.816 silk.c ..Add codec 16000
    10:32:44.816 silk.c ..silk add codecs
    10:32:44.816 silk.c ..Add codec 12000
    10:32:44.816 silk.c ..silk add codecs
    10:32:44.816 silk.c ..Add codec 8000
    10:32:44.816 pj_opus.c ..Init opus
    10:32:44.816 pj_opus.c ..Init opus > DONE
    10:32:44.816 pj_opus.c ..opus enum codecs
    10:32:44.816 sip_endpoint.c ..Module “mod-opus-sdp-rewriter” registered
    10:32:44.816 conference.c ..Creating conference bridge with 254 ports
    10:32:44.816 Master/sound ..Using delay buffer with WSOLA.
    10:32:44.818 pjsua_vid.c ..Initializing video subsystem..
    10:32:44.818 ffmpeg_vid_cod …Cannot find H261 encoder in ffmpeg library
    10:32:44.818 ffmpeg_vid_cod …Cannot find H261 decoder in ffmpeg library
    10:32:44.818 pj_vpx.c …Init vpx codec
    10:32:44.818 pj_vpx.c …Enum codecs…
    10:32:44.822 dshow_dev.c …Windows found no video input devices
    10:32:44.822 dshow_dev.c …DShow has 0 devices:
    10:32:44.827 sdl_dev.c …SDL 1.3 initialized
    10:32:44.827 colorbar_dev.c …Colorbar video src initialized with 2 device(s):
    10:32:44.827 colorbar_dev.c … 0: Colorbar generator
    10:32:44.827 colorbar_dev.c … 1: Colorbar-active
    10:32:44.827 sip_endpoint.c .Module “mod-evsub” registered
    10:32:44.827 sip_endpoint.c .Module “mod-presence” registered
    10:32:44.827 evsub.c .Event pkg “presence” registered by mod-presence
    10:32:44.827 sip_endpoint.c .Module “mod-mwi” registered
    10:32:44.827 evsub.c .Event pkg “message-summary” registered by mod-mwi
    10:32:44.827 sip_endpoint.c .Module “mod-refer” registered
    10:32:44.827 evsub.c .Event pkg “refer” registered by mod-refer
    10:32:44.827 sip_endpoint.c .Module “mod-pjsua-pres” registered
    10:32:44.827 sip_endpoint.c .Module “mod-pjsua-im” registered
    10:32:44.827 sip_endpoint.c .Module “mod-pjsua-options” registered
    10:32:44.827 pjsua_core.c .1 SIP worker threads created
    10:32:44.827 pjsua_core.c .pjsua version 2.6 for win32-6.2/i386/msvc-15.0 initialized
    10:32:44.827 pjsua_core.c .PJSUA state changed: CREATED –> INIT
    10:32:44.827 pjsua_core.c PJSUA state changed: INIT –> STARTING
    10:32:44.827 sip_endpoint.c .Module “mod-unsolicited-mwi” registered
    10:32:44.827 pjsua_core.c .PJSUA state changed: STARTING –> RUNNING
    10:32:44.828 silk.c silk default attr
    10:32:44.828 silk.c silk default attr
    10:32:44.828 silk.c silk default attr
    10:32:44.828 silk.c silk default attr
    10:32:44.830 pjsua_core.c SIP UDP socket reachable at 192.168.50.7:63994
    10:32:44.830 udp01523F68 SIP UDP transport started, published address is 192.168.50.7:63994
    10:32:44.832 tcptp:2505 SIP TCP listener ready for incoming connections at 192.168.50.7:2505
    10:32:44.834 tlstp:2506 SIP TLS listener is ready for incoming connections at 192.168.50.7:2506
    10:32:44.834 pjsua_acc.c Adding account: id=
    10:32:44.835 pjsua_acc.c .Account added with id 0
    10:32:44.835 pjsua_acc.c .Acc 0: setting registration..
    10:32:44.835 endpoint ..Request msg REGISTER/cseq=26747 (tdta0152BBA8) created.
    10:32:44.835 tsx0152CC14 …Transaction created for Request msg REGISTER/cseq=26748 (tdta0152BBA8)
    10:32:44.835 tsx0152CC14 ..Sending Request msg REGISTER/cseq=26748 (tdta0152BBA8) in state Null
    10:32:44.835 sip_resolve.c …Target ‘219.137.176.128:0’ type=Unspecified resolved to ‘219.137.176.128:5060’ type=UDP (UDP transport)
    10:32:44.835 pjsua_core.c …TX 573 bytes Request msg REGISTER/cseq=26748 (tdta0152BBA8) to UDP 219.137.176.128:5060:
    REGISTER sip:gd.ctcims.cn SIP/2.0

    Via: SIP/2.0/UDP 192.168.50.7:63994;rport;branch=z9hG4bKPj1af244a6d82f456da22934bb35288332

    Route:

    Max-Forwards: 70

    From: ;tag=14165e8eae0e491aae36d79d25ab5da9

    To:

    Call-ID: 266faef82a90470c94d7c6b71cbaeb8a

    CSeq: 26748 REGISTER

    User-Agent: MicroSIP/3.15.3

    Contact:

    Expires: 300

    Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS

    Content-Length: 0

    –end msg–
    10:32:44.835 tsx0152CC14 …State changed from Null to Calling, event=TX_MSG
    10:32:44.835 pjsua_acc.c ..Acc 0: Registration sent
    10:32:44.835 pjsua_acc.c Acc 0: setting online status to 1..
    10:32:44.895 sip_endpoint.c !Processing incoming message: Response msg 423/REGISTER/cseq=26748 (rdata01528844)
    10:32:44.895 pjsua_core.c .RX 501 bytes Response msg 423/REGISTER/cseq=26748 (rdata01528844) from UDP 219.137.176.128:5060:
    SIP/2.0 423 Interval Too Brief

    Via: SIP/2.0/UDP 192.168.50.7:63994;received=192.168.50.7;rport=63994;branch=z9hG4bKPj1af244a6d82f456da22934bb35288332

    To: ;tag=ztesipNk5lI0FL6VGC*3-3-16648*daa.3

    From: ;tag=14165e8eae0e491aae36d79d25ab5da9

    Call-ID: 266faef82a90470c94d7c6b71cbaeb8a

    CSeq: 26748 REGISTER

    X-ZTE-Cause: “CSCF-3.3.0xBC00161B-0xBC001505-0xBC0015D3-0xBC00151E@scscf04.gd.ctcims.cn”

    Min-Expires: 1800

    Content-Length: 0

    –end msg–
    10:32:44.895 tsx0152CC14 .Incoming Response msg 423/REGISTER/cseq=26748 (rdata01528844) in state Calling
    10:32:44.895 tsx0152CC14 ..State changed from Calling to Completed, event=RX_MSG
    10:32:44.896 endpoint …Request msg REGISTER/cseq=26748 (tdta0152F300) created.
    10:32:44.896 tsx0153036C ….Transaction created for Request msg REGISTER/cseq=26749 (tdta0152F300)
    10:32:44.896 tsx0153036C …Sending Request msg REGISTER/cseq=26749 (tdta0152F300) in state Null
    10:32:44.896 sip_resolve.c ….Target ‘219.137.176.128:0’ type=Unspecified resolved to ‘219.137.176.128:5060’ type=UDP (UDP transport)
    10:32:44.896 pjsua_core.c ….TX 574 bytes Request msg REGISTER/cseq=26749 (tdta0152F300) to UDP 219.137.176.128:5060:
    REGISTER sip:gd.ctcims.cn SIP/2.0

    Via: SIP/2.0/UDP 192.168.50.7:63994;rport;branch=z9hG4bKPj04c1f323ac1c49ed9d7446092e54177f

    Route:

    Max-Forwards: 70

    From: ;tag=10838b74c81b4b49bc1322f8fe82107f

    To:

    Call-ID: 266faef82a90470c94d7c6b71cbaeb8a

    CSeq: 26749 REGISTER

    User-Agent: MicroSIP/3.15.3

    Contact:

    Expires: 1800

    Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS

    Content-Length: 0

    –end msg–
    10:32:44.896 tsx0153036C ….State changed from Null to Calling, event=TX_MSG
    10:32:44.984 sip_endpoint.c Processing incoming message: Response msg 401/REGISTER/cseq=26749 (rdata01528844)
    10:32:44.984 pjsua_core.c .RX 567 bytes Response msg 401/REGISTER/cseq=26749 (rdata01528844) from UDP 219.137.176.128:5060:
    SIP/2.0 401 Unauthorized

    Via: SIP/2.0/UDP 192.168.50.7:63994;received=192.168.50.7;rport=63994;branch=z9hG4bKPj04c1f323ac1c49ed9d7446092e54177f

    To: ;tag=ztesip27CO6h6o0*3-3-16648*daf.3

    From: ;tag=10838b74c81b4b49bc1322f8fe82107f

    Call-ID: 266faef82a90470c94d7c6b71cbaeb8a

    CSeq: 26749 REGISTER

    Content-Length: 0

    WWW-Authenticate: Digest realm=”gd.ctcims.cn”,domain=”sip:scscf04.gd.ctcims.cn”,nonce=”9bae5d773dbf0957a12e0c97736d666f”,opaque=”aW1zLmNvbS5jbg==”,stale=TRUE,algorithm=MD5,qop=”auth”

    –end msg–
    10:32:44.984 tsx0153036C .Incoming Response msg 401/REGISTER/cseq=26749 (rdata01528844) in state Calling
    10:32:44.984 tsx0153036C ..State changed from Calling to Completed, event=RX_MSG
    10:32:44.985 tsx01532EC4 ….Transaction created for Request msg REGISTER/cseq=26750 (tdta0152F300)
    10:32:44.985 tsx01532EC4 …Sending Request msg REGISTER/cseq=26750 (tdta0152F300) in state Null
    10:32:44.985 endpoint ….Request msg REGISTER/cseq=26750 (tdta0152F300): skipping target resolution because address is already set
    10:32:44.985 pjsua_core.c ….TX 876 bytes Request msg REGISTER/cseq=26750 (tdta0152F300) to UDP 219.137.176.128:5060:
    REGISTER sip:gd.ctcims.cn SIP/2.0

    Via: SIP/2.0/UDP 192.168.50.7:63994;rport;branch=z9hG4bKPj5be701ce71d84352a2afd781693275c6

    Route:

    Max-Forwards: 70

    From: ;tag=10838b74c81b4b49bc1322f8fe82107f

    To:

    Call-ID: 266faef82a90470c94d7c6b71cbaeb8a

    CSeq: 26750 REGISTER

    User-Agent: MicroSIP/3.15.3

    Contact:

    Expires: 1800

    Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS

    Authorization: Digest username=”+862037612170@gd.ctcims.cn”, realm=”gd.ctcims.cn”, nonce=”9bae5d773dbf0957a12e0c97736d666f”, uri=”sip:gd.ctcims.cn”, response=”1359ce93b333c19aace6529b3fc99e64″, algorithm=MD5, cnonce=”b1ad16da92514bcaa72d53a2b52e0a6f”, opaque=”aW1zLmNvbS5jbg==”, qop=auth, nc=00000001

    Content-Length: 0

    –end msg–
    10:32:44.985 tsx01532EC4 ….State changed from Null to Calling, event=TX_MSG
    10:32:45.075 sip_endpoint.c Processing incoming message: Response msg 200/REGISTER/cseq=26750 (rdata01528844)
    10:32:45.075 pjsua_core.c .RX 747 bytes Response msg 200/REGISTER/cseq=26750 (rdata01528844) from UDP 219.137.176.128:5060:
    SIP/2.0 200 OK

    Via: SIP/2.0/UDP 192.168.50.7:63994;received=192.168.50.7;rport=63994;branch=z9hG4bKPj5be701ce71d84352a2afd781693275c6

    To: ;tag=ztesipuBtX2SQqSHu_vE15_O*3-3-16648*dba.3

    From: ;tag=10838b74c81b4b49bc1322f8fe82107f

    Call-ID: 266faef82a90470c94d7c6b71cbaeb8a

    CSeq: 26750 REGISTER

    Contact: ;expires=300

    P-Associated-URI:

    P-Associated-URI:

    Date: Tue, 02 May 2017 02:32:39 GMT

    Authentication-Info: nextnonce=”3d510648940e4c12d7d95bb5d04b2954″,qop=auth,rspauth=”2b296868aae622ed91d44c81d8cfb9b8″,cnonce=”b1ad16da92514bcaa72d53a2b52e0a6f”,nc=00000001

    Content-Length: 0

    –end msg–
    10:32:45.075 tsx01532EC4 .Incoming Response msg 200/REGISTER/cseq=26750 (rdata01528844) in state Calling
    10:32:45.076 tsx01532EC4 ..State changed from Calling to Completed, event=RX_MSG
    10:32:45.076 pjsua_acc.c ….SIP outbound status for acc 0 is not active
    10:32:45.076 pjsua_acc.c ….: registration success, status=200 (OK), will re-register in 300 seconds
    10:32:45.076 pjsua_acc.c ….Keep-alive timer started for acc 0, destination:219.137.176.128:5060, interval:15s
    10:32:49.896 tsx0152CC14 Timeout timer event
    10:32:49.896 tsx0152CC14 .State changed from Completed to Terminated, event=TIMER
    10:32:49.896 tsx0152CC14 Timeout timer event
    10:32:49.896 tsx0152CC14 .State changed from Terminated to Destroyed, event=TIMER
    10:32:49.896 tdta0152BBA8 ..Destroying txdata Request msg REGISTER/cseq=26748 (tdta0152BBA8)
    10:32:49.896 tsx0152CC14 Transaction destroyed!
    10:32:49.986 tsx0153036C Timeout timer event
    10:32:49.986 tsx0153036C .State changed from Completed to Terminated, event=TIMER
    10:32:49.986 tsx0153036C Timeout timer event
    10:32:49.986 tsx0153036C .State changed from Terminated to Destroyed, event=TIMER
    10:32:49.986 tsx0153036C Transaction destroyed!
    10:32:50.076 tsx01532EC4 Timeout timer event
    10:32:50.076 tsx01532EC4 .State changed from Completed to Terminated, event=TIMER
    10:32:50.076 tsx01532EC4 Timeout timer event
    10:32:50.076 tsx01532EC4 .State changed from Terminated to Destroyed, event=TIMER
    10:32:50.076 tdta0152F300 ..Destroying txdata Request msg REGISTER/cseq=26750 (tdta0152F300)
    10:32:50.076 tsx01532EC4 Transaction destroyed!
    10:33:00.076 pjsua_acc.c Sending 2 bytes keep-alive packet for acc 0 to 219.137.176.128:5060
    10:33:00.076 tdta0152BBA8 Destroying txdata raw

  • george

    我也是上海电信的,但好像下载不到配置密码,能否留个联系方式请教一下。

    谢谢

发表评论

电子邮件地址不会被公开。 必填项已用*标注