Asterisk chan_sip freezes when there's no internet

A.G.A.

Joined
Jul 20, 2008
Messages
33
Likes
0
Points
0
#1
got problem:
i have two almost "out of box" installations of Elastix.
versions are 1.1.8 and 1.2 RC2 and both of them have the same issue.

when i add external SIP trunk from VoIP-provider with REGISTER string - it still works, and able to receive calls from VoIP, ZAP etc

when my external DSL link goes down, registration fails:
"sip show registry" shows that external provider is unreachable - that's OK,
BUT:
1. Asterisk stops responding on incoming ZAP calls, even if they are routed to LOCAL sip phones
2. i can't place calls from internal SIP-phones.
SIP calls are not routed at all.
IAX soft-phones still can work normally.
it looks like CHAN_SIP.SO is FROZEN at all - until i put internet cable back.

when i don't use REGISTER statement, internal SIP, IAX and ZAP calls are routed without any dependency on internet connection - as it should be.
 

A.G.A.

Joined
Jul 20, 2008
Messages
33
Likes
0
Points
0
#2
"register string" is like this:

sip_registrations.conf:

register=USER4232:password@212.53.40.40/3686871

---------------------

when internet link is alive, registration is OK, all calls are routed well

*CLI> sip show registry
Host Username Refresh State Reg.Time
212.53.40.40:5060 USER4232 105 Registered Mon, 08 Sep 2008 23:01:22


---------------------

when internet link is down, registration is broken:

*CLI> sip show registry
Host Username Refresh State Reg.Time
212.53.40.40:5060 USER4232 105 Request Sent Mon, 08 Sep 2008 23:05:13

no SIP calls are routed at all - external, internall, from ZAP to internall etc
 

wiseoldowl

Joined
Aug 19, 2008
Messages
251
Likes
0
Points
0
#3
This is a longstanding, somewhat well known bug in Asterisk itself. I don't know if they ever plan to fix it, but if they do it will probably be in the 1.6 branch (maybe they will backport it and maybe they won't). This is the sort of bug that so frustrates Asterisk users and developers, because Digium knows about the issue but so far hasn't done anything about it (as far as I know).

As I understand it, the problem is only present if you have one or more SIP trunks. If you only have one SIP trunk, there is an off chance that local (extension to extension) calls may still go through, albeit very slowly. If you have two or more SIP trunks, then local calls will timeout while Asterisk twiddles its thumbs waiting for the SIP trunks to connect, and the local calls will time out and never connect.

I don't know how to find my way around the Asterisk bug tracking system, otherwise I might be able to show you where the bug has been reported. However it affects ALL distributions that use Asterisk. It only affects SIP channels, so if (for example) you have two softphones that use IAX protocol (e.g. Zoiper), they will be able to place calls back and forth, but SIP-based extensions will be unable to communicate.
 

A.G.A.

Joined
Jul 20, 2008
Messages
33
Likes
0
Points
0
#4
thank's for attention.
there was a discussion http://forums.whirlpool.net.au/forum-re ... m?t=960451
i can't make it clear: is DNS resolution the source of problem, or lost connectivity to voip is the problem itself.
tried to change all FQDN names of VoIP to IP addresses - it did not help.
tried to create the "dumb trunk" that is always accessible - using OpenSER installation on the same machine - it did not help too.
really frustrating - i think hybrid PBX that falls down completely when it looses internet connectivity is useless.
 

A.G.A.

Joined
Jul 20, 2008
Messages
33
Likes
0
Points
0
#5
after some research, found that chan_sip freezes when it cannot resolve SRV names like _sip._udp.somedomain (when we have lost internet connection, and DNS is outside).

changing all host.domain names to ip-addresses and adding string "srvlookup=no" to sip_general_custom.conf works like antifreeze.

not very beutyfull, but better then denial of service.
 

icbnsys

Joined
Nov 27, 2007
Messages
20
Likes
0
Points
0
#6
I bumped on the same thread in whirlpool.net.au. Dummy trunks using SPA and VM did not work for me also. I have couple of servers currently migrating to Elastix and it seems that this issue is more noticed than with the previous one.

My SIP provider specifically define to put srvlookup=yes in sip_general_custom.conf, anyways I tried it and confirm that chan_sip is not freezing but he timeout keep on repeating so call set-ups is delayed from time to time.

The problem is very repeatable so it is easy to compare between testings. I found that DNS resolution for SIP trunks is not the issue since with local caching DNS and non-caching, the result is just the same when I force asterisk to reload it config
 

wiseoldowl

Joined
Aug 19, 2008
Messages
251
Likes
0
Points
0
#7
I tried posting a feature request to handle this issue on the FreePBX bug tracker, as you can see it didn't get very far for the moment:

http://www.freepbx.org/trac/ticket/3199

Subsequently there was a discussion with a few people on IRC. There were two points I took away from that. One is that the IRC commenters seemed to agree that using a FQDN is the cause of the issue - if you can use a static IP (dotted IP address, such as 12.34.56.78) then (they say) you don't have the problem. Of course, the only issue with that is that if the provider changes fixed IP addresses and repoints the FQDN to point to the new IP, then you would not pick that change up and may lose connectivity to that provider. Maybe someone could make a script that would look up a FQDN and plug the address it points to into the correct trunk config at regular intervals, but the problem with THAT is that the setting is probably stored in the MySQL database and rewritten when ever you change FreePBX configuration. So you'd have to change the static IP address in the MySQL database and then cause FreePBX to reload... that does not sound easy at all.

philippel (the head developer of FreePBX) thought that something like dnsmasq might address the issue. His suggestion was that you run something like dnsmasq on your PBX, and you make sure that the local PBX is resolving from that cache (he said it requires a few 'tricks' from the standard dnsmasq config). Then you point dnsmasq to what ever your real dns sever is. He said that he thinks there is information in dnsmasq readme, you just have to be aware that is your desired setup, otherwise the server where dnsmasq is running will actually go to the real dns server, but a quick and dirty test is set dnsmasq up on a different server in your network, and point your asterisk server to that server as the dns source, then you don't have to worry about the issue for testing purposes. You can install it using "yum install dnsmasq" (he said it's on the dag repository???) and then you'll have to review the config...

The dnsmasq "man" page is at http://www.thekelleys.org.uk/dnsmasq/do ... q-man.html and there's an additional doc page at http://www.thekelleys.org.uk/dnsmasq/doc.html

Unfortunately I am not a Linux guru so most of that was pretty much over my head. One other point that was made on IRC is that something related to DNS was fixed in Asterisk 1.6 (it's in the changelog) but the person who mentioned that did NOT know if the change was related to this particular issue. If it was, I sure wish they'd backport it.

If anyone DOES figure out how to use dnsmasq to resolve the issue, it would be very helpful if you could post step-by-step, "cookbook" type instructions so those of us who have difficulty doing anything in Linux could get this to work!
 

A.G.A.

Joined
Jul 20, 2008
Messages
33
Likes
0
Points
0
#8
i'm completely new to linux too :)

so, as far as i understand, dnsmasq is just a caching-only dns-server, which you can setup on a pbx machine.

somewhere i found this step by step (sorry, i did not save authors name) how to setup local dns caching only server:

1. Install cache only name server on the Asterisk server (BIND with caching configuration)
yum -y install caching-nameserver
chkconfig --add named
chkconfig --level 345 named on
echo "* IN A 127.0.0.2" >> /var/named/localdomain.zone
service named start

2. Set Asterisk as its own DNS server by adding 127.0.0.1 on the first line of /etc/resolve.conf, like
127.0.0.1
your.other.dns.servers

3. Make sure Asterisk has default settings for file /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=your_asterisk_server_name.localdomain
(Do not change HOSTNAME to your_asterisk_server_name.yourdomain.com )

4. Then in file /etc/hosts, something like
127.0.0.1 your_asterisk_server_name.localdomain your_asterisk_server_name localhost.localdomain localhost

i've tried this setup. it works well for DNS names resolution,
and it helps against the issue. sometimes :)
i did not take a long testing, but i found that in some hours SIP goes to bad again.

changing "srvlookup" to "no" helped me better - no faults at all.

need more testing.
 

icbnsys

Joined
Nov 27, 2007
Messages
20
Likes
0
Points
0
#9
Dotted IP on SIP trunks does not help for me.

I use caching DNS all the time but this will just delay the problem and would appear the system to be unreliable. Asterisk pass DNS resolution to the O/S, I don't think centOS has DNS resolution issue.

I now found the script posted at TB before that monitors internet. Once I can get some positive results on my testing, I will post it here.

icbnsys
 

icbnsys

Joined
Nov 27, 2007
Messages
20
Likes
0
Points
0
#10
Here is the modified script. Results of my test server indicates at least 10 minutes to fail over when internet is down after that everything is OK. When internet returns it can quickly recover. Pls use and modify at your own risk.


#!/usr/bin/perl
#icheck.pl

# In the event of internet loss, Asterisk SIP channel doesn't work very
# well. The channel will become very busy registering the trunk to it
# SIP providers that tends to hung-up the server. The SIP registration
# time-out seems forever. This conditions was reported on some sites
# with NAT connection to some SOHO routers.

# This script will replace the SIP registration file with the one with
# registration entries removed.
# When internet connectivity is restored it is swapped back. Asterisk
# will be reloaded every time config is swapped. You should run this as
# a cron job, say every five minutes.

# For internet connection with dynamic IP address, host file need also to
# be modified so that the server host name will be bind to 127.0.0.1
# and removed this binding when internet returns so that the server will
# be resolved to the correct public IP not to the localhost.

# Incorrect host resolution may lead to one-way audio problem on remote
# extensions.

# How to install:
# Backup your sip registration and hosts file in a safe place. Remove
# all registration entries on sip registration file. Backup hosts file
# should contain this entry, add if needed:
# 127.0.0.1 myhost.dyndomain.com
# Save this files as bb_no_sipregistration and bb_no_hosts.
# Then create this file "vi /root/icheck.pl". Set permisson to "chmod
# uog+x".

# Contab settings:
# */5 * * * * /usr/bin/perl /root/icheck.pl

# No changes needed for hosts file if you have internet with static IP.

# Do not load or reload freePBX web gui SIP Trunks when internet is down
# since it will auto-generate sip_registrations.conf file.

use Net::ping;

my $ip = "198.65.166.131"; # host you want to test for connectivity
my $bb_no_sipregistrations = "/etc/asterisk/bb_no_sipregistrations.conf";
my $bb_ok_sipregistrations = "/etc/asterisk/bb_ok_sipregistrations.conf";
my $running_sipregistrations = "/etc/asterisk/sip_registrations.conf";
my $bb_no_hosts = "/etc/bb_no_hosts";
my $bb_ok_hosts = "/etc/bb_ok_hosts";
my $running_hosts = "/etc/hosts";
my $bb_status = 0; # assume Internet is Down
my $wait = 5;

$p = Net::ping->new("icmp"); # use icmp ping to desired destination
if ($p->ping($ip) )
{
# Internet is Up
print "Internet is Up.... ";
$bb_status = 1;
if ((-e $bb_ok_sipregistrations)) # check the default version of the config file
{
# Rename active hosts file to no-internet version
# rename (old name, new name)
# Load default version hosts file
# rename (old name, new name)

rename($running_sipregistrations,$bb_no_sipregistrations);
rename($bb_ok_sipregistrations,$running_sipregistrations);
# comment 2 lines below if you have Fix IP.
rename($running_hosts,$bb_no_hosts);
rename($bb_ok_hosts,$running_hosts);

print "loading default config filesn";
print "restarting asteriskn";
system("service asterisk reload"); # reload asterisk
}
else {
print "No status changen";
}
}
else {
print "Internet is Down.... ";
$bb_status = 0;
if ((-e $bb_no_sipregistrations)) # check to see if the no-internet version
{
# Rename active hosts file to default version
# rename (old name, new name)
# Load no-internet version hosts file
# rename (old name, new name)

rename($running_sipregistrations,$bb_ok_sipregistrations);
rename($bb_no_sipregistrations,$running_sipregistrations);
# comment 2 lines below if you have Fix IP.
rename($running_hosts,$bb_ok_hosts);
rename($bb_no_hosts,$running_hosts);

print "loading back-up config filesn";
print "restarting asteriskn";
system("service asterisk reload"); # reload asterisk
exit;
}
else {
print "No status changen";
exit;
}
}


icbnsys
icybernet at gmail dot com http://forum.elastix.org/old_files/icheck.txt
 

wiseoldowl

Joined
Aug 19, 2008
Messages
251
Likes
0
Points
0
#11
Okay, maybe I'm really dense here, but I don't see how this can work as shown.

You say:

# Backup your sip registration and hosts file in a safe place. Remove
# all registration entries on sip registration file. Backup hosts file
# should contain this entry, add if needed:
# 127.0.0.1 myhost.dyndomain.com
# Save this files as bb_no_sipregistration and bb_no_hosts.

So obviously you intend that these backup files be different from the "normal" sip registration and hosts files. However, when you run the perl script and the Internet is "up" you do this:

# Rename active hosts file to no-internet version
# rename (old name, new name)
# Load default version hosts file
# rename (old name, new name)

rename($running_sipregistrations,$bb_no_sipregistrations); <--- huh???
rename($bb_ok_sipregistrations,$running_sipregistrations);
# comment 2 lines below if you have Fix IP.
rename($running_hosts,$bb_no_hosts); <--- huh???
rename($bb_ok_hosts,$running_hosts);

So doesn't this OVERWRITE all the changes you've made in your "backup" sip registration and hosts files, rendering them useless for the purpose intended? I'm just asking - maybe there's something in this code that I'm not seeing, but at first look it doesn't seem like this can possibly work as intended.

And there is another possibly fatal flaw in the logic here - you say:

# Do not load or reload freePBX web gui SIP Trunks when internet is down
# since it will auto-generate sip_registrations.conf file.

Okay, but if you do that when the Internet is UP, shouldn't there be something to copy the changed file to bb_ok_sipregistrations.conf so if the Internet goes down and then comes back up, you're not suddenly working with an old configuration file?

I'm not saying the basic idea isn't good, it just looks to me like the actual implementation is perhaps a bit flawed - either that, or I'm just not "getting it" (which is entirely possible).

If I knew how to program it (I probably could but it would take me days, not minutes, since I'm not that knowledgeable in Perl), I'd rather see a version of this that doesn't use backup files at all, but instead simply comments out the lines in sip_registrations.conf that need to be ignored when the Internet is down, and then removes those comments when the Internet is back up. In other words, when the Internet is DOWN, it would look at sip_registrations.conf and if it sees any lines that begin with "register=" it would prepend a ; to comment out such lines, then rewrite the file. Once the Internet comes back up, it would do the opposite, scanning that file for any lines that begin with ;register= and if it finds any, remove the ; at the start of such lines, and then rewrite the file. That way, if the file should get modified by FreePBX during an outage, it would only be an issue for five minutes at most, and when the 'net comes back up a correct file would be restored.

As for etc/hosts, I'm really lost on that - I already have a line in the form:
127.0.0.1 myhost.dyndomain.com
in that file, and it doesn't cause any problems with sip trunking. If it needs to be there during a loss of Internet, then why not just add it to etc/hosts and be done with it? Why go to the trouble of switching hosts files around at all?
 

A.G.A.

Joined
Jul 20, 2008
Messages
33
Likes
0
Points
0
#12
i think it's better to manipulate with sip_registrations_custom.conf, since it's not controlled by free pbx.
 

wiseoldowl

Joined
Aug 19, 2008
Messages
251
Likes
0
Points
0
#13
flexdv said:
i think it's better to manipulate with sip_registrations_custom.conf, since it's not controlled by free pbx.
Only one small problem with that thought: the stuff that needs to be removed or commented out during an Internet outage isn't in sip_registrations_custom.conf
 

icbnsys

Joined
Nov 27, 2007
Messages
20
Likes
0
Points
0
#14
Swapping sip_registrations_custom.conf is also a good option. It now depends on user preference. The idea is to get rid of any registration entry.

Commenting 127.0.0.1 myhost.dyndomain.com entry on hosts file is for one-way audio problem when using remote SIP extensions not a SIP trunk problem.

icbnsys
 

wiseoldowl

Joined
Aug 19, 2008
Messages
251
Likes
0
Points
0
#15
icbnsys said:
Commenting 127.0.0.1 myhost.dyndomain.com entry on hosts file is for one-way audio problem when using remote SIP extensions not a SIP trunk problem.
Well, we have remote SIP extensions, too, and don't experience one-way audio with 127.0.0.1 myhost.dyndomain.com - I guess I'm just wondering why you would not simply leave that entry in your hosts file permanently, or why it would have to be changed based on the state of your internet connectivity.

In fact, the ONLY thing that we have ever found that cures one-way audio (for extensions AND trunks) is to have the necessary lines in sip_nat.conf:

nat=yes
externip=12.34.56.78 (replace with your external IP address)
fromdomain=myhost.dyndomain.com (replace with your dynamic address)
localnet=192.168.0.0/255.255.255.0 (use appropriate settings for your local network)

Some people will tell you to use externhost rather than externip and fromdomain, but for some reason we've never been able to get that to work, whereas the above in sip_nat conf works reliably. The only problem is that the external IP can be changed by the ISP (it happens rarely, but it does happen) so we have a perl script that checks the external IP every five minutes, and rewrites sip_nat conf (changing the target of the externip line) if it has changed.

But the point I am trying to make is that at least in my experience, the hosts file has nothing to do with one-way audio and there is no reason I can see to modify the hosts file based on whether or not you currently have Internet connectivity. We have a line of the form 127.0.0.1 myhost.dyndomain.com in the etc/hosts file all the time; I just can't see any advantage to removing it. But of course you are free to do whatever you like on your system.
 

icbnsys

Joined
Nov 27, 2007
Messages
20
Likes
0
Points
0
#16
Hosts file "/etc/hosts" is part of DNS resolution where in fact it is look-up 1st than your primary DNS during the resolution of hostname to dotted IP addresses. During the event of internet failure, you lost your external DNS server, even your local caching DNS is also lost when it releases its cache based on the TTL value of the hosts stored. Your hosts file is your only chance to get your SIP Trunks resolved else * will wait forever.

If you are aware your * is also a SIP server, likewise need to be resolved all the time. When your internet is normal, the resolution will be handled by your DNS which it passed ultimately to the authority which is your DynDNS registrar. Note that dynamic IP has very short TTL value of about 60 secs. So when you lost your internet, it is quicky erased from cache, that will be the time to bind it to your localhost.

Somehow if your * has improper resolution i.e. 127.0.0.1 during normal operation, your SIP device used for external extension gets that IP address as your SIP server thus send the audio to herself. This is the cause of one-way audio. Not all SIP device is behaving like this though. From your console, you can verify by pinging what is the actual myhost.dyndomain.com is resolving.

I write my hosts file like this. Below is a portion showing the SIP Trunks.

--default hosts file--
# SIP Trunks IP addresses
# 127.0.0.1 myhost.dyndomain.com
# 199.221.62.198 proxy.siptrunk1.com
# 190.65.166.131 proxy.siptrunk2.com
# 205.11.192.23 proxy.siptrunk2.com

--no-internet hosts file--
# SIP Trunks IP addresses
127.0.0.1 myhost.dyndomain.com
199.221.62.198 proxy.siptrunk1.com
190.65.166.131 proxy.siptrunk2.com
205.11.192.23 proxy.siptrunk2.com

My comment on sip_nat.conf, * provides 2 options to declare your host where you can select one. You make it appear that you have a fix IP when in fact the one you have is a dynamic. By creating a script to monitor the actual IP Address is like overriding the DynDNS registrar which is supposedly the authority. DNS resolution is accurate and fast, more faster than 5 minutes, so why reinvent the wheel.

icbnsys
 

A.G.A.

Joined
Jul 20, 2008
Messages
33
Likes
0
Points
0
#17
adding addresses to hosts file will not help.

* tryes to resolve SRV records for your "register" entries.

with "tcpdump -A port 53" you can see something like this:
02:34:54.939902 IP 192.168.92.13.33414 > ns.vmts.ru.domain: 10426+ SRV? _sip._udp.212.53.40.40. (40)
02:35:00.939820 IP 192.168.92.13.33414 > dns.primorye.net.ru.domain: 9517+ SRV? _sip._udp.212.53.40.40.localhost. (50)


* hangs, when it can not resolve SRV records,
but you can not add this records into hosts file.

you need to disable srv lookups by adding "srvlookup=no" to sip_general_custom.conf

then, i think it's better to add IP-addresses (not FQDN) to sip_registrations_custom.conf

for the case, if our provider change ip-adresses, we need a script for changing IP's in
sip_registrations_custom.conf

----------------------------------------------------------
in other words - take name resolution process away from Asterisk.
 

icbnsys

Joined
Nov 27, 2007
Messages
20
Likes
0
Points
0
#18
Hosts file resolve only one IP Address, no weight is expected. When asterisk tries to resolve proxy.siptrunk1.com, she gets a time-out error. That is enough to stop her from waiting. It is a dummy to help some SOHO routers with limited memory and processor.

Legacy router handles this time-out well. A value for money.
 

wiseoldowl

Joined
Aug 19, 2008
Messages
251
Likes
0
Points
0
#19
icbnsys said:
Somehow if your * has improper resolution i.e. 127.0.0.1 during normal operation, your SIP device used for external extension gets that IP address as your SIP server thus send the audio to herself. This is the cause of one-way audio.
Baloney. The hosts file has nothing to do with one-way audio issues.

I write my hosts file like this. Below is a portion showing the SIP Trunks.

--default hosts file--
# SIP Trunks IP addresses
# 127.0.0.1 myhost.dyndomain.com
# 199.221.62.198 proxy.siptrunk1.com
# 190.65.166.131 proxy.siptrunk2.com
# 205.11.192.23 proxy.siptrunk2.com

--no-internet hosts file--
# SIP Trunks IP addresses
127.0.0.1 myhost.dyndomain.com
199.221.62.198 proxy.siptrunk1.com
190.65.166.131 proxy.siptrunk2.com
205.11.192.23 proxy.siptrunk2.com
We use a hosts file similar to your second example (particularly with regard to the line defining 127.0.0.1) all the time, regardless of the state of Internet connectivity. It does not cause one-way audio. And by the way, why on earth would you copy over a file where every line is commented out?

My comment on sip_nat.conf, * provides 2 options to declare your host where you can select one. You make it appear that you have a fix IP when in fact the one you have is a dynamic. By creating a script to monitor the actual IP Address is like overriding the DynDNS registrar which is supposedly the authority. DNS resolution is accurate and fast, more faster than 5 minutes, so why reinvent the wheel.
Because the other option (externhost) DOES NOT WORK RELIABLY in the 1.2 or 1.4 branches of Asterisk. Perhaps they have finally fixed it in 1.6, but if you try to use it in 1.2 or 1.4 it simply does not fix the one-way audio issue.

As I said before, I'm not trying to tell you what to do with your system. If it makes you feel better to do unnecessary file swaps, by all means do so. But there's no reason you can't have a single hosts file that works all the time, and in any case it makes no sense to copy over a "do nothing" file where every line is commented out. I will also mention that my comments are based on actual experience - our system is behind a NAT firewall and we have struggled with one-way audio problems, but the fix had nothing to do with the hosts file!

By the way, I did not quote nor reply to the first couple paragraphs of your post, because you are trying to explain something fairly technical and it is apparent that English is not your primary language. Honestly, I couldn't make heads or tails of what you were trying to say.
 

wiseoldowl

Joined
Aug 19, 2008
Messages
251
Likes
0
Points
0
#20
flexdv said:
then, i think it's better to add IP-addresses (not FQDN) to sip_registrations_custom.conf

for the case, if our provider change ip-adresses, we need a script for changing IP's in
sip_registrations_custom.conf
This perl script modifies sip_nat.conf when the external IP address changes, but maybe you can adapt it to your needs. Unlike some scripts, it actually tries to verify that it's getting a valid IP address before it rewrites the file. Note the line that starts with %configvars - do NOT change the 0.0.0.0 in that line, but DO change the "yourdyndnsdomain.com" and (if necessary) the localnet settings.

Note that you may need to use Webmin's perl modules admin page (or whatever other method you prefer) to install any missing perl modules.


Code:
#!/usr/bin/perl
#
#This program gets the current IP address (as assigned by the ISP) from
#whatismyip.org and modifies etc/asterisk/sip_nat.conf if the external IP
#address has changed. Use Webmin to invoke it as cron job that runs every 5 mins
#
use strict;
use warnings;
use WWW::Mechanize;
use Tie::IxHash;
use Data::Validate::IP qw(is_public_ipv4);
my $s_filepath = "/etc/asterisk/sip_nat.conf";
my $mech = WWW::Mechanize->new( autocheck => 1 );
$mech->get('http://whatismyip.com/automation/n09230945.asp');
$mech->success or die 'Cannot connect to http://whatismyip.com/automation/n09230945.asp';
my ($ip) = ($mech->content() =~ /(\d+\.\d+\.\d+\.\d+)/);
if (is_public_ipv4($ip)) {
	tie my %configvars, 'Tie::IxHash';
	%configvars = ('nat' => 'yes', 'externip' => '0.0.0.0','fromdomain' => 'your.dyndnsdomain.com','localnet' => '192.168.0.0/255.255.255.0') ;
	open IN,"<$s_filepath";
	while (my $i = <IN>) {
		chop $i;
		if ($i =~ /=/) {
			$i =~ s/\s//g;
			my ($key,$value) = split /=/,$i;
			$configvars{$key} = $value;
		}
	}
	close IN;
	if ($configvars{'externip'} ne $ip) {
		$configvars{'externip'} = $ip;
		open OUT,">$s_filepath";
		while (my ($key, $value) = each %configvars) {
			select OUT;
			print "$key=$value\n";
		};
		select STDOUT;
		close OUT;
		`/usr/sbin/asterisk -rx reload`;
	};
};
 

Members online

No members online now.

Latest posts

Forum statistics

Threads
30,902
Messages
130,887
Members
17,565
Latest member
omarmenichetti
Top