[SR-Users] Kamailio in cloud environments

Sergey Safarov s.safarov at gmail.com
Mon Nov 11 06:00:46 CET 2019


You can also update kamailio.cfg to include listeners.cfg
Example. Need add to kamailio.cfg

####### Listeners ##########
include_file "/var/run/kamailio/listeners-eth0.cfg"

Before kamailio started you will generate listeners.cfg file.
This may by done by drop-in file.
Need create "/etc/systemd/system/kamailio.service.d/10-listners-eth0.conf"
with content
[Service]
ExecStartPre=/bin/curl -s -S --output /var/run/kamailio/listeners-eth0.cfg
http://169.254.169.254/latest/meta-data/public-ipv4
ExecStartPre=/bin/sed --in-place --regexp-extended -e
's/(.*)/listen=udp:\1:5060\nlisten=tcp:\1:5060\n/'
/var/run/kamailio/listeners-eth0.cfg



On Mon, Nov 11, 2019 at 2:50 AM David Villasmil <
david.villasmil.work at gmail.com> wrote:

> That's the one, thanks @Karsten!
>
>
> More info, i changed my systemd unit to execute a script when starting up,
> like so:
>
> # cat /etc/systemd/system/multi-user.target.wants/kamailio.service
> [Unit]
> Description=Kamailio (OpenSER) - the Open Source SIP Server
> After=network.target
>
> [Service]
> Type=forking
> Environment='CFGFILE=/etc/kamailio/kamailio.cfg'
> Environment='SHM_MEMORY=64'
> Environment='PKG_MEMORY=8'
> Environment='USER=kamailio'
> Environment='GROUP=kamailio'
> EnvironmentFile=-/etc/default/kamailio
> EnvironmentFile=-/etc/default/kamailio.d/*
> # PIDFile requires a full absolute path
> PIDFile=/var/run/kamailio/kamailio.pid
> ExecStart=/etc/kamailio/startkam.sh
> Restart=on-abort
>
> [Install]
> WantedBy=multi-user.target
>
> And /etc/kamailio/startkam.sh is like:
>
> #!/bin/bash
>
> MYSQL=$(/etc/kamailio/aws-getpass.sh dev us-east-1 dburl)
> SHM_MEMORY=64
> PKG_MEMORY=8
> USER=kamailio
> GROUP=kamailio
> CFGFILE=/etc/kamailio/kamailio.cfg
> /usr/sbin/kamailio -P /var/run/kamailio/kamailio.pid -f $CFGFILE -m
> $SHM_MEMORY -M $PKG_MEMORY -u $USER -g $GROUP -A "DBURL=\"$MYSQL\"" -A
> "CBDBURL=\"cb=>$MYSQL\"" -A "ASGDBURL=\"asg=>$MYSQL\""
>
> which in turn calls /etc/kamailio/aws-getpass.sh, which is the actual
> script talking to AWS via BOTO3 to get the data i need.
>
> You can just change the params and use them in your kam script normally
> like:
>
> modparam("acc", "db_url", DBURL )
>
> Hope that helps.
>
> Regards,
>
> David Villasmil
> email: david.villasmil.work at gmail.com
> phone: +34669448337
>
>
> On Sun, Nov 10, 2019 at 9:22 PM Alex Balashov <abalashov at evaristesys.com>
> wrote:
>
>> -A ... oh wow. That's savvy! Cheers.
>>
>> On Sun, Nov 10, 2019 at 08:51:59PM +0100, Karsten Horsmann wrote:
>>
>> > Hi David,
>> >
>> > You mean this thread from may 2019.
>> > https://lists.kamailio.org/pipermail/sr-users/2019-May/105599.html
>> >
>> > Pro Tipp, search on lists.kamailio.org/pipermail/ to get your link.
>> Great
>> > help the mailing list archive btw.
>> >
>> > Cheers
>> > Karsten
>> >
>> > David Villasmil <david.villasmil.work at gmail.com> schrieb am So., 10.
>> Nov.
>> > 2019, 19:03:
>> >
>> > > I needed to discover the user/pass for the dB when kamailio starts so
>> as
>> > > not to store it locally. I get the data via an AWS script, then start
>> > > kamailio passing the parameters, then use of those in the script. You
>> can
>> > > do exactly this to get and set the current ip address.
>> > >
>> > > I don’t know how to share a thread from this mailing list, but search
>> for
>> > > the subject “ define a DBURL with SLQOPS fails” and you will find all
>> info
>> > > there.
>> > >
>> > > On Sun, 10 Nov 2019 at 17:48, Alex Balashov <
>> abalashov at evaristesys.com>
>> > > wrote:
>> > >
>> > >> On Sun, Nov 10, 2019 at 06:16:44PM +0100, Alejandro Recarey wrote:
>> > >>
>> > >> > Hi, I am trying to get kamailio working cloud provider, autoscaling
>> > >> > them behind a TCP load balancer.
>> > >> >
>> > >> > Is there a way for kamailio to discover its Public IP at startup?
>> Or
>> > >> > do people generally program their own startup scripts that modify
>> the
>> > >> > kamailio config file before starting it?
>> > >>
>> > >> They generally do the latter, especially since public IP discovery
>> > >> mechanisms tend to be specific to the cloud provider.
>> > >>
>> > >> But various templating mechanisms make this quite easy to do.
>> > >>
>> > >> --
>> > >> Alex Balashov | Principal | Evariste Systems LLC
>> > >>
>> > >> Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free)
>> > >> Web: http://www.evaristesys.com/, http://www.csrpswitch.com/
>> > >>
>> > >> _______________________________________________
>> > >> Kamailio (SER) - Users Mailing List
>> > >> sr-users at lists.kamailio.org
>> > >> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>> > >>
>> > > --
>> > > Regards,
>> > >
>> > > David Villasmil
>> > > email: david.villasmil.work at gmail.com
>> > > phone: +34669448337
>> > > _______________________________________________
>> > > Kamailio (SER) - Users Mailing List
>> > > sr-users at lists.kamailio.org
>> > > https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>> > >
>>
>> > _______________________________________________
>> > Kamailio (SER) - Users Mailing List
>> > sr-users at lists.kamailio.org
>> > https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>
>>
>> --
>> Alex Balashov | Principal | Evariste Systems LLC
>>
>> Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free)
>> Web: http://www.evaristesys.com/, http://www.csrpswitch.com/
>>
>> _______________________________________________
>> Kamailio (SER) - Users Mailing List
>> sr-users at lists.kamailio.org
>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>
> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users at lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20191111/15fd9008/attachment.html>


More information about the sr-users mailing list