Some records about sip server internal network mapping external network

Reposted from: http://xiaominfc.com/sip/2018/03/26/%E5%85%B3%E4%BA%8Esip-server%E5%86%85%E7%BD%91%E6%98%A0 %E5%B0%84%E5%A4%96%E7%BD%91%E7%9A%84%E4%B8%80%E4%BA%9B%E8%AE%B0%E5%BD%95.html

 

Preface


1. 公司要搞个呼叫中心
2. 用了sip这套方案
3. 买了GSM<=>sip的卡机
4. 卡机架设在内网
5. 外网放了个freepbx的sip server
freepbx 能通过卡机 拨打手机号

1 Port mapping (the card machine is mapped to an ip on the external network)

Beginning with the ngrok, but not ngrok only supports tcp, universal github I found people to write frp support dup (sip server also supports tcp transmission but by default with udp to default to a less change some configuration) card machine Of 5060 udp is mapped out

2 Dial

The dialer receives the call normally, but there is no sound. . . . . Various conjectures (the operator blocked the rtp package). . . . . I feel so cute. . . . . The reason is that the voice transmission rtp is divided into two lines. . . . . The card machine on the internal network may be able to access the external network but the external network may not be able to access the card machine. So what should I do if there is a problem with the voice packet transmission? Supplement various information. Well, the common solution is nat internal network penetration. Finally, a coturn is installed on the external network to provide the stun service to configure the card machine to have sound. . . . . (Fumbling for the modification of the configuration for a long time is really unfamiliar with these)

3 Hang up

It is strange that both parties on the phone cannot receive each other's on-hook event. . . . . . . Hey, there are all kinds of events that can be seen, but there is no hang up. . . . . . I feel something is wrong. . . . . . I want to change various configurations, but they are all useless. To put it bluntly, what should I do if I do a blind experiment without theoretical guidance? I am getting familiar with the sip protocol by supplementing various materials, taking the old ways to capture packets, various packages Invite, 100Trying, 180Ringing, 200OK. Ok no more no ACK package

1.多亏frp开源 又是用golang开发了
2.研究了一下源码 好吧frp是这么回事呀
3.改。。。。。。

There are packages. . . . . The format is right. . . . . I guessed that the ACK was sent in the wrong place. . . . . . Thinking of changing the sip package at the frp level, I looked at the various ip addresses in the sip package and changed it. It was another attempt without theoretical guidance and made up various information. I happened to see the article SIP INVITE: Contact Header  Suddenly, it turned out that the value of the Contact field was wrong. Check carefully and found that although the port of the card machine is indeed mapped to the external network, the Contact in the sip packet sent by the card machine during the sip transmission is always the external network corresponding to this internal network. IP and the card machine must receive re-INVITE, BYE, ACK, these packets are all sent to the address written by Contact, so I changed the source code of frp and processed the value of Contact to the external network ip and port we mapped to. Then the ACK packet is received. . . . . . . . .

ps

It’s more helpful to understand the problem and solve the problem.

Guess you like

Origin blog.csdn.net/gouguofei/article/details/108776773