tpgalan
tpgalan

Reputation: 196

Asterisk sip.conf in MySQL database

I'm able to include a phone inside a database for realtime usage. So, this code (from /etc/asterisk/sip.conf):

[phone]
type=friend
username=phone
secret=12345
host=dynamic
disallow=all
allow=g729
allow=alaw
context=somecontext
nat=no
insecure=port,invite

it is now inside a database (using MySQL).

Now, I want to include a SIP trunk using the register directive, but I don't know how to do that.

How can I include register => <username>:<password>@<provider> inside the database as well?

Upvotes: 1

Views: 2935

Answers (2)

mlast
mlast

Reputation: 1

The register directive should be a static entry in sip.conf [general] section, so while you could do this with static realtime, you may then have problems loading dynamic realtime users.

Your best option may be to use the #exec directive in sip.conf. This will allow you to run a script to read that register line from a db string.

To do this, you will need to enable 'execinclude = yes' in asterisk.conf and then add a line in sip.conf [general] section to run your script, like: #exec /etc/asterisk/scripts/your_script_file

Here is a nice example from Leif Madsen using #exec to set externip= paramater via a php script: https://leifmadsen.wordpress.com/2011/02/27/using-exec-to-set-externaddr-in-sip-conf/

Upvotes: 0

arheops
arheops

Reputation: 15259

You have 2 options.

1) static realtime. Just put in mysql line-by-line whole file

https://www.voip-info.org/asterisk-realtime-static

In this mode when you issue asterisk reload it just read from database line-by-line and interpret it as text file.

2) dynamic realtime.

In this mode asterisk check database only when have request for auth and only for matched peers.

https://www.voip-info.org/asterisk-realtime-sip/

Use regserver param to put your registration server.

Upvotes: 1

Related Questions