Elastix dies when there is no internet connection

Mirko87

Joined
Oct 20, 2008
Messages
128
Likes
0
Points
0
#21
Hi guys..
I'm back with the script..:)

You can download from here: Get The Script

So that.. It is in a .tar file, but it is a .php.

The function are:

Every minutes (on the base of the potions you configure in the crontab) it gets a ping to www.google.it (you can cange the site, n.d.r.).

If there is no reply:
1-Modify the FreePBX table for the SIP Trunks that have the register field with a value (the VoIP Trunks), and set '1' in the field 'flags'.
2-It modify the parameter that show the trunk is disabled ("globals" => "OUTDISABLE_XX = on" ). wiseoldowl: try this.. I've found it, but I'm not sure that it works..
3-execute the restore of the configuration ('retrieve_conf' ).
4-Gets the Reload of Asterisk

If the the reply return:
1-Re-Modify the field 'flag' of the VoIP Trunk with the original value..
2-Re-Modify the parameter that show the Trunk is disabled (with enabled)
3-execute the restore of the configuration ('retrieve_conf' ).
4-Gets the Reload of Asterisk

If the Script disable a Trunk, on FreePBX you'll see the Trunk is disabled.

If you gets a modify on FreePBX the System continue to works so good!!

DNSChace don't care, if you have it is a good thing, but it isn't essential.

If some calls are up... Them don't go down (Internal calls logically).

Download the tar and decompress it in: /var/lib/asterisk/bin
Add into the crontab: * * * * * /usr/bin/php /var/lib/asterisk/bin/our_checktrunkvoip.php

Taht is the solution that I found, but now I can't try it because I'm translating a lot of audio files :S, I hope this is ok... If not I can get some questions to the developers...

See you soon... I back to work...

Mirko
 

wiseoldowl

Joined
Aug 19, 2008
Messages
251
Likes
0
Points
0
#22
Okay, for those who downloaded that script and are trying to figure out what it does, here it is with the comments and text strings translated into English (using online translators and trying to apply a little common sense, still I do not guarantee this is a perfect translation). Oh, and it's set to check google.com instead of google.it, although I personally would suggest it might be better to use something a little "closer" (like your ISP's home site, if it will accept ping requests), and it might even be good to check two sites, in case one is down. I HAVE NOT YET TESTED THIS - I don't know PHP so I'm still trying to figure out how it works, and I want to know before I turn it loose on my system!

Oops, forum software mangles the code - try this:
http://filebin.ca/meufoy/english_checktrunkvoip.php
 

Mirko87

Joined
Oct 20, 2008
Messages
128
Likes
0
Points
0
#23
All right...

Now I havto to go to work.. But tomorrow morning I'll get a look at the script (I don't know so much PHP... I don't use it by 3 years when I was a student, but I can try to understand it)...

So that, if you don't understand something in the script because is write in Italian... Make me some question, and I'll translate to you...

If I have some time, I can translate all for the offcial version of the script... There is no problem...

See you soon...

Mirko
 

wiseoldowl

Joined
Aug 19, 2008
Messages
251
Likes
0
Points
0
#24
Bob,

I don't know if you saw my previous message (about how Asterisk was simply ignoring my trunks and they weren't showing up in sip show peers when I tried to use dnsmasq) but anyway, I THINK I may have figured out part of the problem. In your instructions for editing dnsmasq.conf, you only have us add the server= line. But if you look above that, you see this:

# Change this line if you want dns to get its upstream servers from
# somewhere other that /etc/resolv.conf
#resolv-file=

And a bit below that...

# If you don't want dnsmasq to read /etc/resolv.conf or any other
# file, getting its servers from this file instead (see below), then
# uncomment this.
#no-resolv

# If you don't want dnsmasq to poll /etc/resolv.conf or other resolv
# files for changes and re-read them then uncomment this.
#no-poll

Now it seems to me that if dnsmasq looks to /etc/resolv.conf first, we have a problem, because that file contains this (assuming you have changed the DNS lookup in Elastix):

nameserver 127.0.0.1

So I tried uncommenting these lines in dnsmasq.conf:
no-resolv
no-poll

And that ALMOST worked. I say ALMOST because of one major problem: On a reboot, Asterisk apparently doesn't get whatever information it needs from dnsmasq. I suspect this is a timing issue, that perhaps dnsmasq isn't fully initialized by the time Asterisk is up and running. If I stop and restart Asterisk then it appears to work as expected (at least my trunks show up in sip show peers) but if for any reason Asterisk reboots and you don't stop and restart it after the reboot, it doesn't find the trunks. So until and unless we can find a reliable solution for that issue, this won't work - I can't have Asterisk coming up in a half-dead state (where it cannot access sip trunks) after a reboot.

What I know about Linux you could almost write on the head of a pin, so I don't know if there is any way to make sure that dnsmasq is fully loaded and working before the system attempts to bring up Asterisk, and I'm not 100% sure that's the problem anyway.
 

Mirko87

Joined
Oct 20, 2008
Messages
128
Likes
0
Points
0
#25
Hi..

Have you try the script?

wiseoldowl...I've placed yesterday morning in my system... with the line in the crontab, and my elastix is still working so good!!...
Now I've got to try to remove the connection when I can.

Mirko
 

Mirko87

Joined
Oct 20, 2008
Messages
128
Likes
0
Points
0
#26
Hi again...

Just for information... Now I'm back in office, and when I try to call my Server say to me: "All circuits are busy now, please try your call again later"...

For make my PBX useful again I re-configurated the trunk... And now It's ok, but for the moment I have removed the line for the crontab...

But the strange thing is that in early morning, when I get the bug, I couldn't call a voip provider, but when I calls my mobile it works...

I have to check it more in the next days...

See you soon

Mirko
 

Bob

Joined
Nov 4, 2007
Messages
2,400
Likes
1
Points
36
#27
Wiseoldowl and others,

Sorry for the delay in returning to the forum, especially after posting the info on DNSMASQ.

I have just read the thread in its entirety - boy it has been busy!!

Wiseoldowl, you understanding of the some the issues are very close. I spent some time looking at some of the issues.

1) DNSMASQ fails to load if Networking has not initialised in a reasonable timeframe, and is worse with DHCP. This explains the earlier posts that DNSMASQ did not start up for some users. I rebooted my system 10 times, and got two failures. So this is an issue.

2) DNSMASQ even if it does load, may not load in time for Asterisk. This means that Asterisk cannot resolve DNS addresses, which in turn will screw up the SIP comms. So this is an issue.

In terms of the server parameter, I believe that I have got that setting correct. The choice with DNSMASQ is

1) have it look at the resolv.conf for upstream servers (which Elastix uses to hold DNS Server)
2) Have it look at another file for upstream servers (increase complexity)
3) manually specify upstream servers (the method I chose).

When DNSMASQ and Asterisk are running, the settings I have used work well. The main issue to deal with is to resolve this loading order issue.

Leave it with me....

Regards

Bob
 

userfromca

Joined
Jun 30, 2007
Messages
30
Likes
0
Points
0
#28
I am the original poster of this thread. Everybody who contributed, thank you.

I have two incoming zap (DAHDI) lines for PSTN connected via X100P on the Elastix box. (Before you purists start screaming, this setup has been working fine for 6 months with Hylafax and this problem has nothing to do with X100P, I hope ;-)

My elastix is connected to a switch that connects to my firewall/router WAN connection. It is easy for me to disconnect the wire from WAN on this switch. Rest of the phones and elastix still stays connected. This is how I test for failure.

I have implemented caching DNS but as Bob correctly pointed (I missed it), I had secondary DNS pointing to opendns.org. Now I am pointing all dns to 127.0.0.1 for Elastix server. I did not have a chance to disconnect WAN port yet but I hope to do it next Wed. during scheduled downtime. I did try rebooting the firewall once and making an outgoing/incoming calls without rebooting Elastix. This sure worked.
 

tolengo

Joined
Oct 31, 2008
Messages
117
Likes
0
Points
0
#29
I had sip trunks with registration strings and Elastix died when the internet fell down, i wrote that this occurs just with SIP registrations.


I had a really easy idea and i delete all regitrations strings of all active trunks, then Elastix could run as normaly. I think that the 1/2 solution is just create a script which will ping 24 hours a day and in case the ping cuts, just it will disable our regitrations in sip_registrations.conf and all will be in function normally.


What do you thing about?
May somebody already has this script :)

good luck.

Johnny
 

wiseoldowl

Joined
Aug 19, 2008
Messages
251
Likes
0
Points
0
#30
Mirko87 said:
Hi..

Have you try the script?

wiseoldowl...I've placed yesterday morning in my system... with the line in the crontab, and my elastix is still working so good!!...
Now I've got to try to remove the connection when I can.

Mirko
I'm just wondering if you've had a chance to test your script thoroughly... this topic keeps coming up (most recently here). The two reasons I am reluctant to try your script are that it only pings ONE site before declaring the connection down (which is obviously a problem if only that one site is down) - I'd want it to check TWO sites at a minimum, and if either one is up then the Internet is up. And, I don't know PHP so I don't know what the script is doing, and I don't know how to fix the aforementioned issue.

A comment on this ticket says that this problem is resolved in Asterisk 1.6.1 (not any earlier versions) so let's hope that is true... of course I don't know when Elastix will make the jump to the 1.6 branch.
 

tolengo

Joined
Oct 31, 2008
Messages
117
Likes
0
Points
0
#31
I haven't the script yet but this week i want to try it, i will paste it here.

hasta pronto :)

johnny
 

wiseoldowl

Joined
Aug 19, 2008
Messages
251
Likes
0
Points
0
#32
I know this is an old thread, but just came across this and wanted to pass it along. From Review of Foncordiax Telephone Systems (Foncordiax and Foncordia PABX are other distributions based on FreePBX, similar to Elastix):

DNS BIND
A DNS (bind version 9.3.4) server is also loaded and available for use in the event there is no other DNS service locally available during deployment. (Asterisk has some issues with SIP connections if it loses its bead on the DNS server). During testing
 

mbit

Joined
Jul 4, 2007
Messages
466
Likes
0
Points
0
#33
BIND definitely solves the issue. I have installed it on my Elastix machine and I can disconnect the internet and my sip extensions still work as normal.
 

wiseoldowl

Joined
Aug 19, 2008
Messages
251
Likes
0
Points
0
#34
mbit said:
BIND definitely solves the issue. I have installed it on my Elastix machine and I can disconnect the internet and my sip extensions still work as normal.
Did you figure out how to do that on your own, or did you happen to find some instructions on how to do it? Would be interested in seeing some good, clear (as in, not written for a Linux networking guru) instructions for setting it up.
 

mbit

Joined
Jul 4, 2007
Messages
466
Likes
0
Points
0
#35
Re:Elastix dies when there is no internet connecti

I will create a vm of the new 1.52 and see the easiest way to setup Bind.

I used to spend a lot of time on these projects but the guys from elastix ignored me so i don't spend much time on them. Ill see what i can do.
 

mbit

Joined
Jul 4, 2007
Messages
466
Likes
0
Points
0
#36
Ok here is how to do it. I have used Webmin which is a bit of a cheat but it should make it easy for you to. This tutorial is not fully complete. If you are having problems with SIP and your internet connection this tute will fix the issue.

Install bind

"yum install bind bind-utils bind-libs bind-chroot caching-nameserver"

Once this is installed install webmin. You can get it from www.webmin.com. I have installed version 1.45.

Then login to webmin and go to servers and into the bind server setup.

First thing it may ask you is to set as primary DNS and start server. Click yes to this and continue.

On the next screen you should see other dns servers, go into this and put in your ISPs DNS server. Then click save.

Now restart bind. Go into your SSH screen and type "service named restart" and start bind on boot "chkconfig named on".

Go into the elastix gui and go to system then network. In there you will set a DNS server. You need to have the DNS server look back to itself. You can do this by setting the DNS server as 127.0.0.1.

Remember bind caches your DNS as you look it up. So before you disconnect your internet you need to do lookups on the machine for all your SIP providers. This will put them into cache.

Reboot your box and allow asterisk to do look ups on all its sip providers. They should then be in cache and the next time your internet falls over your machine will have all the cache it needs and your SIP extensions will not unregister.
 

tolengo

Joined
Oct 31, 2008
Messages
117
Likes
0
Points
0
#37
I sounds nice, but may should be better to do it without a webmin instalation and just create some extra menu web page in elastix to configure DNSes.

Any ideas? :)

Johnny
 

Bob

Joined
Nov 4, 2007
Messages
2,400
Likes
1
Points
36
#38
Mark,

As you are aware I was working separately on this to replace the Tutorial on Elastix connection.

There are a couple of things I have found (I could ring you - but it will be better posted so that others can add their findings).

The commands I used are as follows

yum -y install bind
yum -y install bind-utils
yum -y install caching-nameserver

The last yum actually installs the configs for it to act as a Cache-Name Server. I found no configuration necessary to it to act as a DNS Cache. I confirmed this by checking the Cache Entries to confirm it was indeed caching the entries.

Also remember in Elastix GUI to replaced DNS Server 1 with 127.0.0.1 and leave DNS Server 2 blank.

The next issue is that Bind will be suitable for system that is running, but if someone reboots the server (while the external DNS is not available), it may still not boot with SIP working, as the cache is flushed each time it is restarted/rebooted. This is due to the Cache being kept in RAM and not a file that can be reloaded. There are other DNS programs that do keep their entries in a file that is reloaded on Boot, but lets see if it is problem first.

However, whilst I have spent some time, it is not as good as having a test rig that exhibits the fault. No matter what I have done (including using a SIP VSP), I cannot get SIP to fail (internally).

Can someone confirm exactly what is setup by answering the following questions if you have one of these systems that fails when DNS goes AWOL.

1) Is your trunks SIP only or a SIP Trunk & IAX trunk
2) On your phones where does your DNS point to (possibly your DHCP setting)
3) On Elastix GUI Setup what DNS entries do you have (e.g. your router, ISP DNS1)
4) If you turn your router off, does this cause the SIP Failure
5) Once the SIP trunk fails to register, is one of the problems that it never seems to retry again?
Any other info to make it a definite fail.

As you are aware, this is not an Elastix issue, but appears to be a failing of the SIP implementation in Asterisk (IAX does not appear to suffer the same fate). I want to see this corrected once and for all. If we can get this done, I am sure that we can push to have the changes made in the next Elastix version..

Bob
 

Bob

Joined
Nov 4, 2007
Messages
2,400
Likes
1
Points
36
#39
Just thought I would add the following of someone is checking that their cache is working

Setup as before, point your Elastix DNS to 127.0.0.1 (itself basically)

ping a couple of unique sites (ones that have nothing to do with Elastix or your VSP)

then issue the following commands

rndc dumpdb
less /var/named/data/cache_dump.db


rndc creates a text file from the DNS Cache that is held in RAM.
when you view the file with less, you should see the DNS entries located in this file that you just pinged.

Regards

Bob
 

tolengo

Joined
Oct 31, 2008
Messages
117
Likes
0
Points
0
#40
I tried with IAX trunks, i unplugged ISP all OK , with sip trunks i get all phones Down, all we know that it is a fatal asterisk core bug, i think resolve this with binds server,scripts,etc is not a correct solution. Asterisk must be repaired boys.
So for now i use a simply script i wrote, some people i know are using it and all works OK.

Sure you have to add more than on ip for more security and add it to cron, enjoy it.

#!/bin/bash
################################################
# CREATED BY JOHNNY TOLENGO madero@email.cz
################################################

#first we need to create a file in /etc/asterisk/register_status
#after this may you want to add to cron to run it
#other thing you can add to this script is some cycle with brakes to ping to more ip addresses its about your security if the one ip will not ping then you will can
#call to the outside by sip so.. be carefull
#nothing more just enjoy it!!

#dont forget comment all the echos

#pide una direccion IP al usuario y reliza un 3 pings con interva

#ip to ping
myip=google.com

#reading the file
ESTADO=`cat /etc/asterisk/register_status`
#extracting the value from de file
VALOR="on"
VALOR2="off"
#ping 3times
#if the ping is active do -->
if $(ping -c3 -i 2 $myip > /dev/null);then

#if status is ON
if [ "$ESTADO" = "$VALOR" ]; then
echo all its OK
#if status is OFF
else
sed -i s/off/on/g /etc/asterisk/register_status
rm -f /etc/asterisk/sip_registrations.conf
mv /etc/asterisk/sip_registrations_backup.conf /etc/asterisk/sip_registrations.conf
echo changed to the original
fi

else
if [ "$ESTADO" = "$VALOR2" ]; then
echo all its ok off status no pinging
#if status is OFF
else
sed -i s/on/off/g /etc/asterisk/register_status
mv /etc/asterisk/sip_registrations.conf /etc/asterisk/sip_registrations_backup.conf
touch /etc/asterisk/sip_registrations.conf
chmod 664 /etc/asterisk/sip_registrations.conf
chown asterisk /etc/asterisk/sip_registrations.conf
chgrp asterisk /etc/asterisk/sip_registrations.conf
echo changed to an empty sip_registrations.conf
fi




fi
 

Members online

No members online now.

Forum statistics

Threads
30,952
Messages
130,980
Members
17,654
Latest member
janko67
Top