Kamailio 源码编译
Kamailio源码编译
一、环境
1、OS:Debian bullseye
2、版本:Kamailio-5.7.2
3、MySQL 5.7
二、编译
1、在Kamailio-5.7.2目录下执行如下指令,生产modules.lst文件
make FLAVOUR=kamailio cfg
2、打开modules.lst文件,找到exclude_modules,将等号后面的db_mysql删除。然后执行编译指令:
make all
3、安装
sudo make install
三、配置
1、打开/usr/local/etc/kamailio/kamailio.cfg,添加如下定义(添加在最顶端即可)。
#!define WITH_MYSQL
#!define WITH_AUTH
#!define WITH_USRLOCDB
#!define WITH_NAT
#!define WITH_DEBUG
2、修改/usr/local/etc/kamailio/kamctlrc
去掉SIP_DOMAIN前的注释,并且修改成自己的服务器地址192.168.1.2。
去掉DBENGINE=MYSQL前的注释语句,选定mysql数据库。
其他的按照如下内容来修改:
# The Kamailio configuration file for the control tools. # Here you can set variables used in the kamctl and kamdbctl setup # scripts. Per default all variables here are commented out, the control tools # will use their internal default values. ## your SIP domain SIP_DOMAIN=192.168.1.2 ## chrooted directory # $CHROOT_DIR="/path/to/chrooted/directory" ## database type: MYSQL, PGSQL, ORACLE, DB_BERKELEY, or DBTEXT, by default none is loaded # If you want to setup a database with kamdbctl, you must at least specify # this parameter. DBENGINE=MYSQL ## database host DBHOST=localhost ## database name (for ORACLE this is TNS name) DBNAME=kamailio # database path used by dbtext or db_berkeley # DB_PATH="/usr/local/etc/kamailio/dbtext" ## database read/write user DBRWUSER=kamailio ## password for database read/write user DBRWPW="kamailiorw" ## database read only user # DBROUSER=kamailioro DBROUSER=kamailioro ## password for database read only user DBROPW=kamailioro ## database super user (for ORACLE this is 'scheme-creator' user) DBROOTUSER="root" # user name column USERCOL="username" # SQL definitions # If you change this definitions here, then you must change them # in db/schema/entities.xml too. # FIXME # FOREVER="2020-05-28 21:32:15" # DEFAULT_ALIASES_EXPIRES=$FOREVER # DEFAULT_Q="1.0" # DEFAULT_CALLID="Default-Call-ID" # DEFAULT_CSEQ="13" # DEFAULT_LOCATION_EXPIRES=$FOREVER # Program to calculate a message-digest fingerprint # MD5="md5sum" # awk tool # AWK="awk" # If you use a system with a grep and egrep that is not 100% gnu grep compatible, # e.g. solaris, install the gnu grep (ggrep) and specify this below. # # grep tool # GREP="grep" # egrep tool # EGREP="egrep" # sed tool # SED="sed" # tail tool # LAST_LINE="tail -n 1" # expr tool # EXPR="expr" # Describe what additional tables to install. Valid values for the variables # below are yes/no/ask. With ask (default) it will interactively ask the user # for an answer, while yes/no allow for automated, unassisted installs. # # If to install tables for the modules in the EXTRA_MODULES variable. # INSTALL_EXTRA_TABLES=ask # If to install presence related tables. # INSTALL_PRESENCE_TABLES=ask # Define what module tables should be installed. # If you use the postgres database and want to change the installed tables, then you # must also adjust the STANDARD_TABLES or EXTRA_TABLES variable accordingly in the # kamdbctl.base script. # kamailio standard modules # STANDARD_MODULES="standard acc lcr domain group permissions registrar usrloc msilo # alias_db uri_db speeddial avpops auth_db pdt dialog dispatcher # dialplan" # Kamailio extra modules # EXTRA_MODULES="imc cpl siptrace domainpolicy carrierroute userblacklist htable purple" ## type of aliases used: DB - database aliases; UL - usrloc aliases ## - default: none # ALIASES_TYPE="DB" ## control engine: FIFO or UNIXSOCK ## - default FIFO # CTLENGINE="FIFO" ## path to FIFO file # OSER_FIFO="FIFO" ## check ACL names; default on (1); off (0) # VERIFY_ACL=1 ## ACL names - if VERIFY_ACL is set, only the ACL names from below list ## are accepted # ACL_GROUPS="local ld int voicemail free-pstn" ## verbose - debug purposes - default '0' VERBOSE=1 ## do (1) or don't (0) store plaintext passwords ## in the subscriber table - default '1' # STORE_PLAINTEXT_PW=0 ## OPENSER START Options ## PID file path - default is: /var/run/Kamailio.pid # PID_FILE=/var/run/kamailio/kamailio.pid PID_FILE=/var/run/kamailio/kamailio.pid ## Extra start options - default is: not set # example: start kamailio with 64MB share memory: STARTOPTIONS="-m 64" # STARTOPTIONS=
3、生成Kamailio的MySQL数据库
执行如下指令生成Kamailio的数据库:
/usr/local/sbin/kamdbctl create
四、启动Kamailio服务
sudo /usr/local/sbin/kamctl start
可以执行“kamailio -c”来检测配置文件是否有错误。
可以执行“kamailio -dddd”,看是否有ERROR输出。
五、注册SIP账号
#kamctl add user1 123456 #kamctl add user2 123456
使用上面的命令添加两个用户 user1和user2 密码都是123456,添加完毕后,配置你的SIP终端注册。
六、Q&A
1、483 Too Many Hops 错误
listen=udp:0.0.0.0:5060
修改为:
listen=udp:192.168.1.2:5060
七、常用命令
1、查找当前sip电话用户
sudo kamctl ul show