My requirement is, I have dynamic users (soft clients) registering to my sip server. I want to register them and clients should be able to make the call.
In /etc/asterisk
extconfig.conf
[settings]
sippeers => mysql,general,ast_sipfriends
res_mysql.conf
[general]
dbhost = 127.0.0.1
dbname = asterisk
dbuser = root
dbpass = <mySQL_DB_Password>
dbport = 3306
requirements = warn
res_odbc.conf
[asterisk]
enabled => yes
dsn => asterisk-connector
username => asterisk
password => <mySQL_DB_Password>
pooling => no
limit => 1
pre-connect => yes
sip.conf
[general]
register=>user:secret@sip.nexmo.com
;registerattempts=0
srvlookup=yes
context=nexmo-sip1
live_dangerously=yes
;nat=force_rport,comedia
;qualify=yes
;nat=no
externip=
localnet=10.0.0.0/255.0.0.0
localnet=192.168.0.0/255.255.0.0
;canreinvite=no
;sipreinvite=no
rtcachefriends=yes
[nexmo-sip]
fromdomain=sip.nexmo.com
type=friend
context=nexmo-sip1
insecure=port,invite
nat=no
;nat=yes
;nat=force_rport,comedia
allow=ulaw
allow=alaw
allow=G729
dtmf=rfc2833
[1001]
type=friend
context=nexmo-sip2
host=dynamic
secret=1001
qualify=yes
;nat=force_rport,comedia
User 1002 is inserted in ast_sipfriends table in asterisk database in mysql
Following output would be confusing to read, so here is the insert statement
insert into asterisk.ast_sipfriends (id,name,callerid,secret,context,host,qualify,type,disallow,allow) values (‘894’,‘1002’,‘1002’,‘1002’,‘nexmo-sip2’,‘dynamic’,‘yes’,‘friend’,‘all’,‘ulaw;alaw’);
±----±------------±------------±------------±---------±------------±--------±------------±-----------±---------±----------±------------±----------±---------±---------±-----------±------------±--------±---------±---------±----------±----±-----±-------±-----±------------±-----±--------±------------±-----------±---------------±-------±---------±----------±------------±-----------±-------±---------------±-------±----------±----------+
| id | name | callerid | defaultuser | regexten | secret | mailbox | accountcode | context | amaflags | callgroup | canreinvite | defaultip | dtmfmode | fromuser | fromdomain | fullcontact | host | insecure | language | md5secret | nat | deny | permit | mask | pickupgroup | port | qualify | restrictcid | rtptimeout | rtpholdtimeout | type | disallow | allow | musiconhold | regseconds | ipaddr | cancallforward | lastms | useragent | regserver |
±----±------------±------------±------------±---------±------------±--------±------------±-----------±---------±----------±------------±----------±---------±---------±-----------±------------±--------±---------±---------±----------±----±-----±-------±-----±------------±-----±--------±------------±-----------±---------------±-------±---------±----------±------------±-----------±-------±---------------±-------±----------±----------+
| 894 | 1002 | 1002 | | | 1002 | NULL | NULL | nexmo-sip2 | NULL | NULL | yes | NULL | NULL | NULL | NULL | NULL | dynamic | NULL | NULL | NULL | no | NULL | NULL | NULL | NULL | | yes | NULL | NULL | NULL | friend | all | ulaw;alaw | NULL | 0 | | yes | 0 | NULL | NULL |
±----±------------±------------±------------±---------±------------±--------±------------±-----------±---------±----------±------------±----------±---------±---------±-----------±------------±--------±---------±---------±----------±----±-----±-------±-----±------------±-----±--------±------------±-----------±---------------±-------±---------±----------±------------±-----------±-------±---------------±-------±----------±----------+
1 row in set (0.00 sec)
In extensions.conf
[general]
;live_dangerously=yes
[globals]
;outbound
[nexmo-sip2]
exten => _X.,1,Dial(SIP/${EXTEN}@nexmo)
[nexmo-sip1]
exten => _X.,1,Dial(SIP/${EXTEN},30)
In /etc
odbc.ini
[asterisk-connector]
Description = MySQL connection to ‘asterisk’ database
Driver = MySQL
Database = asterisk
Server = localhost
UID = asterisk
Password = <mySQL_DB_Password>
Port = 3306
Socket = /var/run/mysqld/mysqld.sock
odbcinst.ini
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so
FileUsage = 1
Issues: a) I get this warning
WARNING[1341]: res_config_mysql.c:335 realtime_mysql: MySQL RealTime: Invalid database specified: general (check res_mysql.conf)
How to fix this?
b) I get this notice when I try to connect 1002 from softclient, which I have inserted in ast_sipfriends
NOTICE[1341]: chan_sip.c:28446 handle_request_register: Registration from ‘sip:1002@mySeverIPAddress’ failed for ‘<myWifiUsedBY_SoftClient>:5060’ - Wrong password
How to fix this?
c) Is it possible to set up asterisk server real time dynamic SIP registration, but not for extensions?
Please help me. Thanks.