This release fixes the Google Voice out bug. So this would then supersede any patching needed to get Google Voice working on Asterisk 1.8
Get it from asterisk.org
Cheers!
Asterisk and Nagios enthusiasts, professionals and consultants based in Kuala Lumpur, Malaysia. Astiostech Sdn Bhd. Asterisk Malaysia. Nagios Malaysia.
This release fixes the Google Voice out bug. So this would then supersede any patching needed to get Google Voice working on Asterisk 1.8
Get it from asterisk.org
Cheers!
If you need to send the proper calling party’s caller ID to a phone when using GoogleTalk, follow the below dialplan. Without any setting, the caller number is set to UNKNOWN and only the CALLERID(name) field is sent with something like sanjayws@gmail.com/Talk.v10471914EB6E. So we tweak the dialplan to show the correct caller ID. Put this dialplan anywhere in your Google incoming dialplan and you should see the calling party just nicely.
exten => stunningsimplicity@gmail.com,n,Set(Thiscallchan=${CALLERID(name)})
exten => stunningsimplicity@gmail.com,n,Set(CALLERID(name)=${CUT(Thiscallchan,/,1)})
exten => stunningsimplicity@gmail.com,n,Set(CALLERID(num)=${CUT(CALLERID(name),@,1)})
Here’s what you will see
**Assuming here, that your diaplan starts with the email address like in a post i did previously below, otherwise, change that accordingly, or change stunningsimplicity to any incoming GoogleVoice email that is expected to land on asterisk.
We remove @gmail.com as it will not quite work with your phones as it will try to do a SIP/IAX @ gmail call.
It’s best to prefix some characters for gmail outbound calling, and in my sample configuration below, i do a g* followed by a google name to dial as we add @gmail in our outbound dialplan. So you can add for incoming a g* automatically like below
exten => stunningsimplicity@gmail.com,n,Set(CALLERID(num)=g*${CUT(CALLERID(name),@,1)})
And so because we add a g* the CallerID(num) field will change to g*sanjayws (where sanjayws is the calling party from an original string received like sanjayws@gmail.com/Talk.v10471914EB6E). Now a person receiving the call can simply redial.UPDATE: Starting with version 0.8.8, the unban operations are now built-in, it is executed through the fail2ban-client app like this
# fail2ban-client set [ban-name]
# e.g. fail2ban-client set asterisk-iptables unbanip 8.8.8.
Check out the changelog here. Get version 0.8.8 here. You really should be upgrading your fail2ban to that above version and use the built-in tool.
[WARNING- THESE BELOW ARE OUTDATED]
Fail2Ban is a great way to protect your server from malicious attempts of brute force and other events that are deemed a problem. It does by very smartly checking your logs and if a particular event is repeated n number of times, you can set actions such as blocking or unblocking using software such as iptables based or software based firewalls or even write scripts to modify an external firewall.
There’s one drawback about it and that is the ability to unban just one IP (many reasons why that might be needed). Just follow these instructions and get the necessary script and you will have an idea or a fully working unban function (if you use iptables to ban)
Version that you MUST USE: Fail2Ban v0.8.4. Download and install Fail2Ban version 0.8.4, for Asterisk fail2banning for SIP brute force attack. Some help with installation here.
This guide was designed on a Debian system. Customization may be required. You can check the version after installing via cli like below
# fail2ban-client –V
Create the unban script, you may need to modify certain settings that would then match your jail setting, actions (in this script its for iptables) and logging options.
# cd /usr/src
# wget http://210.5.42.12/downloads/asterisk/misc/unban
# chmod +x unban
Now, we change or manipulate the actions.py file from Fail2ban for proper handling of unban script unbanning. You may need to modify this if it is not IPtables you use for banning action. See the section def __checkBan in actions.py there’s a modification of an external check command there called mycheck. If mycheck condition is true (returned value 0) it will proceed to ban that IP. The issue we had by just unbaning using the unban script was that fail2ban didn’t know we unban manually using cli. This caused fail2ban to never ban again the IP you just banned because it think that IP is still in its ban list. This “fix” ensures that the process/procedure will check against iptables (or any of your ban action) and reissue a ban if it doesn’t have the IP in its entry (like doing a iptables –n –-list)
# cd /usr/share/fail2ban/server/
# mv actions.py actions.py.original
# wget http://210.5.42.12/downloads/asterisk/misc/actions.py
Restart fail2ban (WARNING, RESTARTS WILL FLUSH ALL BAN IPs OFF THE LIST!)
# /etc/init.d/fail2ban restart
Try it out for yourself to unban some IP
# unban 202.188.0.133
If you do not specify an IP, it will list all banned IPs inside the Jailed context.
nano /etc/asterisk/extensions_override_freepbx.conf |
[macro-user-logoff] ; check device type ; exten => s,1,Set(DEVICETYPE=${DB(DEVICE/${CALLERID(number)}/type)}) exten => s,n,GotoIf($["${DEVICETYPE}" = "fixed"]?s-FIXED,1) exten => s,n,Set(dev=${DB(DEVICE/${CALLERID(num)}/user}) exten => s,n,AGI(kick.sh,${dev}) exten => s,n,AGI(user_login_out.agi,logout,${CALLERID(number)}) exten => s,n(done),Playback(vm-goodbye) exten => s-FIXED,1,NoOp(Device is FIXED and cannot be logged out of) exten => s-FIXED,n,Playback(an-error-has-occured&vm-goodbye) exten => s-FIXED,n,Hangup |
nano /var/lib/asterisk/agi-bin/kick.sh |
#!/bin/bash # script by Sanjay Willie # v0.1-beta # tested on Asterisk 1.6/FreePBX 2.8/Debian 5.06 # maintainer: sanjay@astiostech.com # the directory /tmp should exist and can be accessible by user asterisk and group asterisk # NOTE: FILES IN /tmp normally gets flushed on restarts # On grabbing agent number, should look exactly like "Local/1000@from-queue" eventually and should not contain any preceding or trailing characters # the extraction of agents in the script in the line "for agents..." may or not yield output, so test it out. # The sed part is to remove brackets from the output in the front and back (seen in FBX 2.8) # if the sed isn't required (like in FreePBX 2.7 and below) you can remove it, also lookout for the print $3, in FreePBX 2.7 and below its print $1, so test it out first stdin="0" datenano=`date +%N-%F` regulardate=`date +%F-%T` gennum=$RANDOM-$datenano.int-tmp queuenumbers="4001 4002 4003 5001 5002 5003 4021 4022 4023 5021 5022 5023" ########### while [ "$stdin" != "" ] do read stdin if [ "$stdin" != EOF ] then echo $stdin | grep agi_arg_1 | awk {'print $2'} >> $gennum fi done ############ include=`cat $gennum` #include=2006 ############ cleanup=`rm -v /tmp/$gennum` #echo $cleanup >> /tmp/cleanup ############ if [[ "$include" == "" ]] ; then echo Nothing to do, quitting exit else for queue in $queuenumbers; do #echo $queue >> /tmp/logfile.txt # see NOTES above #for agents in `asterisk -rx "queue show $queue" | grep from-queue | awk '{print $3}' | grep -w "$include" | sed 's/.\(.*\)/\1/' | sed 's/\(.*\)./\1/'`; do # freePBX 2.8 or higher for agents in `asterisk -rx "queue show $queue" | grep from-queue | awk '{print $1}' | grep -w "$include"`; do #echo $agents >> /tmp/logfile.txt asterisk -rx "queue remove member $agents from $queue" echo "we remove $agents in $queue" echo $regulardate - Attempt removing agent $agents from queue $queue >> /tmp/agentremover.log done done fi ############ exit 0 |
asterisk -rx "dialplan reload" |
Now we all know when it comes to clustering its basically one up and the other down. So monitoring, say Exchange or SQL on the live or active one is just fine with all the disk checked and all the services are UP (while set to manual). Problem is when it comes to the passive server, how do we check for just about anything?
Simple. Try using this custom script i’ve written.
Here’s the script snippet.
#!/bin/bash #GET VALUES FROM NAGIOS AND SET THEM AS VARIABLES hostname=$1 # Debug # We check if the quorum is running or not first getoutput=`/usr/local/nagios/libexec/check_nrpe -H $hostname -t 50 -c CheckDriveSize -a ShowAll=long MinWarnFree=10% MinCritFree=5% Drive=q: | grep -c "The system cannot find the path specified"` # DEBUG if [[ "$getoutput" == "1" ]]; then echo "OK: Clustered service is not failed over. We will not check this service now." else /usr/local/nagios/libexec/check_nrpe -H $hostname -t 50 -c checkServiceState -a ShowAll "$servicename" fi |
The idea of this script is to:
1) Check certain resources on the Cluster only if the quorum is alive!
2) If it’s not, send an OK value back to Nagios but in the comment section, mention that “its not failed over” or something.
3) Send fake performance data not to break the Performance Data values.
This value,
getoutput=`/usr/local/nagios/libexec/check_nrpe -H $hostname -t 50 -c CheckDriveSize -a ShowAll=long MinWarnFree=10% MinCritFree=5% Drive=q: | grep -c "The system cannot find the path specified"`
This above checks if the quorum is alive. It is normally the first resource that will fail over. In our case it was drive q!. So, when we are satisfied that the output of the plugin isn’t “…cannot find path”…only then we execute just about any plugin. And in this example above, check the services that are cluster monitored/managed.
Now, to execute the script on commands.cfg, is something like this.
# Check Clustered Services: define command{ } |
On command line, you can simple parse
./check_floating_services <hostname/ip> <servicename>
And there you have it, cluster “enable” plugins.
Cheers!!!!