OpenSIPS 建置筆記

使用 opensips 建立一個 sip server 給內部使用

本文以 debian 9.5 為例 ( opensips v2.2)

安裝 mariadb 當資料庫

apt-get install mariadb-server
mysql_secure_installation

Enter current password for root (enter for none):
Set root password? [Y/n] y
New password:
Re-enter new password:
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y

安裝 opensips

apt-get install opensips opensips-mysql-module

設定

設定監聽 IP

vi /etc/opensips/opensips.cfg

修改監聽 ip 這邊不可以用 127.0.0.1 一定要用你的 ip
然後 alias 設定為 hostname

listen=udp:192.168.1.88:5060
alias=udp:sip.hsps.tp.edu.tw:5060

設定 domain 與資料庫

vi /etc/opensips/opensipsctlrc

SIP_DOMAIN=your.domain.name #設定你的domain
DBENGINE=MYSQL #使用 mysql/mariadb
DBHOST=localhost #資料庫主機
DBNAME=opensips  #資料庫名稱
DBRWUSER=opensips  #SQL帳號
DBRWPW="opensipsrw" #更改為你想設定的密碼

依照上面設定建立 sql 帳號與資料庫

opensipsdbctl create

MySQL password for root: 輸入 mysql root 密碼
Enter character set name: latin1
Install presence related tables? (y/n): y
fraud_detection emergency? (y/n): y

新增 SIP 帳密 (for client)

opensipsctl add 101 101
opensipsctl add 102 102

帳號資料會建立在 table opensips.subscriber

然後就可以通了

設定系統服務

設定開機自動啟動

 systemctl enable opensips

平常操作就

啟動 systemctl start opensips

重啟 systemctl restart opensips

查看狀態 systemctl status opensips