SIP Bind Address

Looking for solution to remove SIP setting bind address from a nightly backup that is auto restored to a warm standby. The backup comes from an HA unit where the bind has to be set. Thanks in advance.

How is the backup being propagated?

If it’s a “mysqldump” file, you can run the file through ‘sed’ and change the specific string you are looking for to anything else you could want. Since this isn’t an HA setup, but a warm backup setup, you are probably kicking the ‘restore’ off from a cronjob or the command line. If so, add "

sed ‘s/whatever:5060/something:5060/g’ < backupsqlfile | mysql -uroot"

No idea if this will work (@xrobau might wish to slap me) but what if you create a local host name on each system that maps to the appropriate ip in /etc/hosts, and then bind chan_sip to the host name?

1 Like

Using FreePBX to reach out and pull a backup from the HA server, then restoring automatically with the Restore Here option in the backup config.

Hello @jyates01,

I would have done it like this:

  1. Preparing a remote backup with excluding the backup configuration options.
  2. running it with the restore here option.
  3. running a post restore hook (BASH script) that will replace the sip bind address in the sip_general_additional.conf and reload the sip configuration

Thank you,

Daniel Friedman
Trixton LTD.

I figured there was some type of script but I just don’t know how to write it.

It doesn’t matter anyway, because it is not effective to directly edit most FreePBX generated files.

In your backup job, have you specifically enabled the option to “Exclude NAT settings”, and if so, does the chan_sip bind address still restore on the target server? If so, I would consider this a bug (or a feature request), as bind address should be excluded with this setting enabled.

Thanks for all the replies. Yes, Exclude NAT is selected and yes it still does restore.

Hello @jyates01,

Just override it with the post restore hook.
You can use a script similar to this (do not try this on your production servers without testing it):

#!/bin/bash
echo 'bindaddr=2.2.2.2' >> /etc/asterisk/sip_general_custom.conf
/usr/sbin/rasterisk -x'sip reload'

Do not forget to update your real ip addresses in the script.

Save it in /var/lib/asterisk/bin/change_bindaddr.sh

Change its permissions and ownership:

chown asterisk. /var/lib/asterisk/bin/change_bindaddr.sh chmod +x /var/lib/asterisk/bin/change_bindaddr.sh

Thank you,

Daniel Friedman
Trixton LTD.

Thanks! Ill give it a shot.

No joy. Back to the drawing board.

try

$(which) mysql --password=password --user=user -D asterisk -e "UPDATE sipsettings SET data='you.ur.ip.com' WHERE keyword='bindaddr' " && $(which fwconsole)  reload

Of course replacing password,user and the ip address as appropriate. you wont need the password if it is not set and then probably user can be root, if that works make sure you have nothing overiding it in /sip_general_custom.conf

http://wiki.freepbx.org/display/FPG/Warm+Spare+Setup#WarmSpareSetup-Network

Exclude NAT settings - Select Yes if you want to exclude any machine-specific IP settings. This allows you to have a warm-spare machine with a different IP address.

@jyates01 if this is not working then open a ticket to have someone take a look, no sense in hacking around with scripts if there is an issue to be fixed.

We never had it ignore the bind address with that setting. Just the nature settings so a feature request would be appropriate here.

Thank you. Will submit one.

Hello @jyates01,

I was not sure if you need that, but you should restart the asterisk server if you are changing the bind address. Your feedback helped me to verify that. So, you will need to add another line in the script that I sent you to this version (replace all the lines in your script):

By the way, you did not mentioned what is your Freepbx version, so, If you are using Freepbx 13 change the amportal to fwconsole (although it will work with amportal as well).

#!/bin/bash
echo 'bindaddr=2.2.2.2' > /etc/asterisk/sip_general_custom.conf
/usr/sbin/rasterisk -x'sip reload'
/usr/local/sbin/amportal restart

Once this feature request will be accepted, you will be able to stop using this script. In the meantime you can use this script to change your bind ip address.

Thank you,

Daniel Friedman
Trixton LTD.

Just getting back around to this, sorry for the delay. Thanks for all the assistance!