Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

168.3. Yate - Yet Another Telephony Engine (includes SIP to H.323 translation)

http://yate.null.ro/pmwiki/

168.3.1. Yate Server

安装编译工具

		
dnf install -y automake g++
			
		
		
cd /usr/local/src/
git clone https://github.com/yatevoip/yate.git
cd yate/
./autogen.sh
./configure
make
make install-noapi
		
		

安装 Yate 服务

		
[root@netkiller yate]# cp packing/rpm/yate.service /etc/systemd/system/		

vim /etc/systemd/system/yate.service

ExecStart=/usr/bin/yate -d -p /var/run/yate.pid $OPTS

改为 

ExecStart=/usr/local/bin/yate -d -p /var/run/yate.pid $OPTS
		
		

配置动态链接库

		
[root@netkiller yate]# echo "/usr/local/lib" > /etc/ld.so.conf.d/local.conf
[root@netkiller yate]# ldconfig
[root@netkiller yate]# yate -V
Yate 6.4.1 devel1 re137d739519b25cc146bd5d9568238072be1b386
		
		

启动 Yate 服务

		
[root@netkiller yate]# systemctl enable yate			
[root@netkiller yate]# systemctl status yate
● yate.service - YATE Telephony Server
     Loaded: loaded (/etc/systemd/system/yate.service; disabled; preset: disabled)
     Active: active (running) since Fri 2025-03-07 08:36:01 CST; 5s ago
       Docs: man:yate(8)
    Process: 3465509 ExecStart=/usr/local/bin/yate -d -p /var/run/yate.pid $OPTS (code=exited, status=0/SUCCESS)
   Main PID: 3465510 (yate)
      Tasks: 18 (limit: 100479)
     Memory: 13.0M
        CPU: 4.920s
     CGroup: /system.slice/yate.service
             ├─3465510 /usr/local/bin/yate -d -p /var/run/yate.pid -F -s -r -l /var/log/yate -vvv -DF
             └─3465511 /usr/local/bin/yate -d -p /var/run/yate.pid -F -s -r -l /var/log/yate -vvv -DF

Mar 07 08:36:01 netkiller systemd[1]: Starting YATE Telephony Server...
Mar 07 08:36:01 netkiller systemd[1]: Started YATE Telephony Server.
		
		
		
[root@netkiller yate]# ss -lnp | grep yate
udp   UNCONN 0      0                         0.0.0.0:4569             0.0.0.0:*    users:(("yate",pid=3466166,fd=6))

udp   UNCONN 0      0                         0.0.0.0:5060             0.0.0.0:*    users:(("yate",pid=3466166,fd=3))

tcp   LISTEN 0      2                         127.0.0.1:5038             0.0.0.0:*    users:(("yate",pid=3466166,fd=5))		
		
		

168.3.2. 配置文件样本

			
[root@netkiller yate]# ls /usr/local/src/yate/conf.d/
accfile.conf.sample       filetransfer.conf.sample  openssl.conf.sample       users.conf.sample
amrnbcodec.conf.sample    gvoice.conf.sample        pbxassist.conf.sample     wiresniff.conf.sample
analog.conf.sample        h323chan.conf.sample      pgsqldb.conf.sample       wpcard.conf.sample
cache.conf.sample         heartbeat.conf.sample     presence.conf.sample      yate.conf.sample
callcounters.conf.sample  hep3_capture.conf.sample  providers.conf.default    yate-qt4.conf.default
callfork.conf.sample      isupmangler.conf.sample   queues.conf.sample        ybladerf.conf.sample
camel_map.conf.sample     jabberclient.conf.sample  queuesnotify.conf.sample  yiaxchan.conf.sample
ccongestion.conf.sample   jabberserver.conf.sample  radiotest.conf.sample     yjinglechan.conf.sample
cdrbuild.conf.sample      javascript.conf.sample    regexroute.conf.sample    yradius.conf.sample
cdrfile.conf.sample       jbfeatures.conf.sample    regfile.conf.sample       yrtpchan.conf.sample
ciscosm.conf.sample       lateroute.conf.sample     register.conf.sample      ysigchan.conf.sample
clustering.conf.sample    lksctp.conf.sample        rmanager.conf.sample      ysipchan.conf.sample
cpuload.conf.sample       Makefile                  sigtransport.conf.sample  ysnmpagent.conf.sample
dbpbx.conf.sample         Makefile.in               sip_cnam_lnp.conf.sample  ysockschan.conf.sample
dsoundchan.conf.sample    mgcpca.conf.sample        sipfeatures.conf.sample   ystunchan.conf.sample
dummyradio.conf.sample    mgcpgw.conf.sample        sqlitedb.conf.sample      zapcard.conf.sample
enumroute.conf.sample     moh.conf.sample           ss7_lnp_ansi.conf.sample  zlibcompress.conf.sample
eventlogs.conf.sample     monitoring.conf.sample    subscription.conf.sample
extmodule.conf.sample     mux.conf.sample           tdmcard.conf.sample
fileinfo.conf.sample      mysqldb.conf.sample       tonegen.conf.sample			
			
		

168.3.3. 添加用户

			
[root@netkiller ~]# cd /usr/local/etc/yate/
[root@netkiller yate]# cp /usr/local/etc/yate/regfile.conf{,.original} 
[root@netkiller yate]# cat >> /usr/local/etc/yate/regfile.conf <<EOF

[100]
password=001

[200]
password=002
EOF

[root@netkiller yate]# egrep -v "^;|^$" /usr/local/etc/yate/regfile.conf
[general]
[100]
password=001
[200]
password=002

[root@netkiller yate]# systemctl restart yate
			
		

168.3.4. regexroute.conf

			
[root@netkiller ~]# cd /usr/local/etc/yate/
[root@netkiller yate]# cp /usr/local/etc/yate/regexroute.conf{,.original} 

[root@netkiller yate]# vim /usr/local/etc/yate/regexroute.conf

加入一行

${username}^$=-;error=noauth

[root@netkiller yate]# egrep -v "^;|^$" /usr/local/etc/yate/regexroute.conf
[priorities]
[$once]
[$init]
[extra]
[contexts]
[default]
^99991001$=tone/dial
^99991002$=tone/busy
^99991003$=tone/ring
^99991004$=tone/specdial
^99991005$=tone/congestion
^99991006$=tone/outoforder
^99991007$=tone/milliwatt
^99991008$=tone/info
${username}^$=-;error=noauth                                                                            127.0.0.1:5038             0.0.0.0:*    users:(("yate",pid=3466166,fd=5))
			
		

168.3.5. 测试

			
[root@netkiller yate]# telnet localhost 5038
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
YATE 6.4.1-devel1 re137d739519b25cc146bd5d9568238072be1b386 (http://YATE.null.ro) ready on netkiller.			
			
		

开启 DEBUG

			
debug on 
color on			
			
		

168.3.6. SBC(SIP Session Border Controller) 会话边界控制器

启用 SBC

			
cp /usr/local/etc/yate/ysipchan.conf{,.original}
cp /usr/local/etc/yate/regexroute.conf{,.original}
			
		
			
[root@netkiller ~]# vim /usr/local/etc/yate/ysipchan.conf
[root@netkiller ~]# egrep -v "^;|^$" /usr/local/etc/yate/ysipchan.conf
[general]
ignorevia=enable			
			
		

/usr/local/etc/yate/regexroute.conf 配置文件加入一行

			
${rtp_forward}possible=;rtp_forward=yes			
			
		

regexroute.conf 配置转发策略

			
[root@netkiller ~]# vim /usr/local/etc/yate/regexroute.conf
[root@netkiller ~]#			
[root@netkiller ~]# egrep -v "^;|^$" /usr/local/etc/yate/regexroute.conf
[priorities]
[$once]
[$init]
[extra]
[contexts]
[default]
^99991001$=tone/dial
^99991002$=tone/busy
^99991003$=tone/ring
^99991004$=tone/specdial
^99991005$=tone/congestion
^99991006$=tone/outoforder
^99991007$=tone/milliwatt
^99991008$=tone/info
${username}^$=-;error=noauth
${rtp_forward}possible=;rtp_forward=yes
			
		

		
[root@netkiller yate]# cp /usr/local/etc/yate/yrtpchan.conf{,.backup}
[root@netkiller yate]# vim /usr/local/etc/yate/yrtpchan.conf
		
		

168.3.7. 配置路由

168.3.7.1. 外拨网关

配置网关

				
[root@netkiller yate]# cp /usr/local/etc/yate/accfile.conf{,.backup}
[root@netkiller yate]# vim /usr/local/etc/yate/accfile.conf
				
				
				
[test_sip]
enabled=yes
protocol=sip
username=6002
description=Test SIP account
interval=600
authname=6002
password=6002
domain=sip.netkiller.cn
registrar=sip.netkiller.cn:5060			
				
				
在 regexroute.conf 文件中加入拨号规则
			
^177$=line/177;line=test_sip			
			
				
查看日志
			
2025-04-13_10:41:53.727273 <INFO> Creating first 1 message dispatching threads
2025-04-13_10:41:53.949674 <sip:ALL> Set party trans_name=(null) proto=UDP local=:0 remote=sip.netkiller.cn:5060 [0x7f9a9c6fe690]
2025-04-13_10:41:53.950591 <sip:INFO> 'udp:0.0.0.0:5066' sending 462 bytes 'REGISTER sip:sip.netkiller.cn:5060' 0x7f9a80002ed0 to 139.9.54.211:5060 [0x1761e10]
-----
REGISTER sip:sip.netkiller.cn:5060 SIP/2.0
Contact: "Test SIP account" <sip:6002@192.168.0.230:5066>
Expires: 600
To: <sip:6002@sip.netkiller.cn>
Via: SIP/2.0/UDP 192.168.0.230:5066;rport;branch=z9hG4bK640589934
From: "Test SIP account" <sip:6002@sip.netkiller.cn>;tag=1024580135
Call-ID: 1863147204@sip.netkiller.cn
CSeq: 1 REGISTER
User-Agent: YATE/6.4.1
Max-Forwards: 70
Allow: ACK, INVITE, BYE, CANCEL, REGISTER, REFER, OPTIONS, INFO
Content-Length: 0

-----
2025-04-13_10:41:53.954645 <sip:INFO> 'udp:0.0.0.0:5066' received 488 bytes SIP message from 139.9.54.211:5060 [0x1761e10]
-----
SIP/2.0 401 Unauthorized
To: <sip:6002@sip.netkiller.cn>;tag=19db6516a6b774c682ff0634f6a75b73.c67d1b36
Via: SIP/2.0/UDP 192.168.0.230:5066;rport=5066;received=121.37.215.251;branch=z9hG4bK640589934
From: "Test SIP account" <sip:6002@sip.netkiller.cn>;tag=1024580135
Call-ID: 1863147204@sip.netkiller.cn
CSeq: 1 REGISTER
WWW-Authenticate: Digest realm="sip.netkiller.cn", nonce="Z/uWHWf7lPGFwDSFrH630CWoTEwIugwM", algorithm=MD5
Server: kamailio (6.0.1 (x86_64/linux))
Content-Length: 0

-----
2025-04-13_10:41:53.956454 <sip:INFO> 'udp:0.0.0.0:5066' sending 658 bytes 'REGISTER sip:sip.netkiller.cn:5060' 0x7f9a8c02fd80 to 139.9.54.211:5060 [0x1761e10]
-----
REGISTER sip:sip.netkiller.cn:5060 SIP/2.0
Contact: "Test SIP account" <sip:6002@192.168.0.230:5066>
Expires: 600
To: <sip:6002@sip.netkiller.cn>
Via: SIP/2.0/UDP 192.168.0.230:5066;rport;branch=z9hG4bK641722837
From: "Test SIP account" <sip:6002@sip.netkiller.cn>;tag=1024580135
Call-ID: 1863147204@sip.netkiller.cn
User-Agent: YATE/6.4.1
Max-Forwards: 70
Allow: ACK, INVITE, BYE, CANCEL, REGISTER, REFER, OPTIONS, INFO
CSeq: 2 REGISTER
Authorization: Digest username="6002", realm="sip.netkiller.cn", nonce="Z/uWHWf7lPGFwDSFrH630CWoTEwIugwM", uri="sip:sip.netkiller.cn:5060", response="71f8d782a165c3fa40dcf7801ddee299", algorithm=MD5
Content-Length: 0

-----
2025-04-13_10:41:53.963424 <sip:INFO> 'udp:0.0.0.0:5066' received 459 bytes SIP message from 139.9.54.211:5060 [0x1761e10]
-----
SIP/2.0 200 OK
To: <sip:6002@sip.netkiller.cn>;tag=19db6516a6b774c682ff0634f6a75b73.514a1b36
Via: SIP/2.0/UDP 192.168.0.230:5066;rport=5066;received=121.37.215.251;branch=z9hG4bK641722837
From: "Test SIP account" <sip:6002@sip.netkiller.cn>;tag=1024580135
Call-ID: 1863147204@sip.netkiller.cn
CSeq: 2 REGISTER
Contact: <sip:6002@192.168.0.230:5066>;expires=600;received="sip:121.37.215.251:5066"
Server: kamailio (6.0.1 (x86_64/linux))
Content-Length: 0

-----
2025-04-13_10:41:53.967334 <sip:INFO> Detected local address 121.37.215.251:5066 for SIP line 'test_sip'
2025-04-13_10:41:53.968079 <sip:CALL> SIP line 'test_sip' logon success to 139.9.54.211:5060
2025-04-13_10:41:56.003924 <sip:INFO> 'udp:0.0.0.0:5066' sending 464 bytes 'REGISTER sip:sip.netkiller.cn:5060' 0x7f9a80006780 to 139.9.54.211:5060 [0x1761e10]
-----
REGISTER sip:sip.netkiller.cn:5060 SIP/2.0
Contact: "Test SIP account" <sip:6002@121.37.215.251:5066>
Expires: 600
To: <sip:6002@sip.netkiller.cn>
Call-ID: 1863147204@sip.netkiller.cn
Via: SIP/2.0/UDP 121.37.215.251:5066;rport;branch=z9hG4bK712598825
From: "Test SIP account" <sip:6002@sip.netkiller.cn>;tag=1708696019
CSeq: 3 REGISTER
User-Agent: YATE/6.4.1
Max-Forwards: 70
Allow: ACK, INVITE, BYE, CANCEL, REGISTER, REFER, OPTIONS, INFO
Content-Length: 0

-----
2025-04-13_10:41:56.007306 <sip:INFO> 'udp:0.0.0.0:5066' received 489 bytes SIP message from 139.9.54.211:5060 [0x1761e10]
-----
SIP/2.0 401 Unauthorized
To: <sip:6002@sip.netkiller.cn>;tag=19db6516a6b774c682ff0634f6a75b73.ac65cb6c
Call-ID: 1863147204@sip.netkiller.cn
Via: SIP/2.0/UDP 121.37.215.251:5066;rport=5066;received=121.37.215.251;branch=z9hG4bK712598825
From: "Test SIP account" <sip:6002@sip.netkiller.cn>;tag=1708696019
CSeq: 3 REGISTER
WWW-Authenticate: Digest realm="sip.netkiller.cn", nonce="Z/uWIGf7lPSNcfm5ONYrypxF8zjHlh1S", algorithm=MD5
Server: kamailio (6.0.1 (x86_64/linux))
Content-Length: 0

-----
2025-04-13_10:41:56.009037 <sip:INFO> 'udp:0.0.0.0:5066' sending 661 bytes 'REGISTER sip:sip.netkiller.cn:5060' 0x7f9a8c0300e0 to 139.9.54.211:5060 [0x1761e10]
-----
REGISTER sip:sip.netkiller.cn:5060 SIP/2.0
Contact: "Test SIP account" <sip:6002@121.37.215.251:5066>
Expires: 600
To: <sip:6002@sip.netkiller.cn>
Call-ID: 1863147204@sip.netkiller.cn
Via: SIP/2.0/UDP 121.37.215.251:5066;rport;branch=z9hG4bK1464071456
From: "Test SIP account" <sip:6002@sip.netkiller.cn>;tag=1708696019
User-Agent: YATE/6.4.1
Max-Forwards: 70
Allow: ACK, INVITE, BYE, CANCEL, REGISTER, REFER, OPTIONS, INFO
CSeq: 4 REGISTER
Authorization: Digest username="6002", realm="sip.netkiller.cn", nonce="Z/uWIGf7lPSNcfm5ONYrypxF8zjHlh1S", uri="sip:sip.netkiller.cn:5060", response="0bd902738a75ca30a59875397828e064", algorithm=MD5
Content-Length: 0

-----
2025-04-13_10:41:56.014974 <sip:INFO> 'udp:0.0.0.0:5066' received 505 bytes SIP message from 139.9.54.211:5060 [0x1761e10]
-----
SIP/2.0 200 OK
To: <sip:6002@sip.netkiller.cn>;tag=19db6516a6b774c682ff0634f6a75b73.93ebcb6c
Call-ID: 1863147204@sip.netkiller.cn
Via: SIP/2.0/UDP 121.37.215.251:5066;rport=5066;received=121.37.215.251;branch=z9hG4bK1464071456
From: "Test SIP account" <sip:6002@sip.netkiller.cn>;tag=1708696019
CSeq: 4 REGISTER
Contact: <sip:6002@192.168.0.230:5066>;expires=597;received="sip:121.37.215.251:5066", <sip:6002@121.37.215.251:5066>;expires=600
Server: kamailio (6.0.1 (x86_64/linux))
Content-Length: 0

-----
2025-04-13_10:41:56.019182 <sip:CALL> SIP line 'test_sip' logon success to 139.9.54.211:5060
2025-04-13_10:42:22.004753 <sip:ALL> Sending UDP keepalive to 139.9.54.211:5060 for 'test_sip'
2025-04-13_10:42:48.000599 <sip:ALL> Sending UDP keepalive to 139.9.54.211:5060 for 'test_sip'
2025-04-13_10:43:14.002343 <sip:ALL> Sending UDP keepalive to 139.9.54.211:5060 for 'test_sip'
2025-04-13_10:43:40.000544 <sip:ALL> Sending UDP keepalive to 139.9.54.211:5060 for 'test_sip'
2025-04-13_10:44:06.000610 <sip:ALL> Sending UDP keepalive to 139.9.54.211:5060 for 'test_sip'			
			
				

168.3.8. 配置会议室

https://docs.yate.ro/wiki/Conference_room_module

168.3.9. Yate Client

http://yateclient.yate.ro/