- Joined
- Dec 3, 2007
- Messages
- 8,069
- Reaction score
- 12
Hi.
Today, everyboby know that exist serveral attack from lots of country.
Iptables must be implemented, and you could accept only some trusted IP.
In this case, when a nomadic remote extension want to connect on Elastix server, you must contact your network admin to accpet your public IP.
I made a stuff to can do it from a phone.
Whe can imagine to enabling this function anoly for some phone number knew like some mobiles.
With an inbound route, you can make a route to forwarding this call on this function shuch reserved for only phone numbers (first security)
You must enter your secret code (47822537 like iptables on the keybord.) to access on this service (Second security)
Third security, the guy must know the line number (DID).
Next you must put your pubic IP like that: 210*23*43*11#
To install it, add this line with visudo:
asterisk ALL=NOPASSWD: /sbin/iptables
(Thanks at Bryce Chidester)
Create a file named format_ip.php into /var/lib/asterisk/agi-bin/
own and grp must be asterisk and with 755
format_ip.php
Add this context on extension_custom.conf
Now just to declare this application on Freepbx.
Enjoy
Today, everyboby know that exist serveral attack from lots of country.
Iptables must be implemented, and you could accept only some trusted IP.
In this case, when a nomadic remote extension want to connect on Elastix server, you must contact your network admin to accpet your public IP.
I made a stuff to can do it from a phone.
Whe can imagine to enabling this function anoly for some phone number knew like some mobiles.
With an inbound route, you can make a route to forwarding this call on this function shuch reserved for only phone numbers (first security)
You must enter your secret code (47822537 like iptables on the keybord.) to access on this service (Second security)
Third security, the guy must know the line number (DID).
Next you must put your pubic IP like that: 210*23*43*11#
To install it, add this line with visudo:
asterisk ALL=NOPASSWD: /sbin/iptables
(Thanks at Bryce Chidester)
Create a file named format_ip.php into /var/lib/asterisk/agi-bin/
own and grp must be asterisk and with 755
format_ip.php
Code:
#!/usr/bin/php -q
<?php
exec("/usr/sbin/asterisk -rx 'database get ip accept'",$cmd);
$result = explode(' ',$cmd[0]);
$ip_formated = str_replace('*','.',$result[1]);
exec("/usr/sbin/asterisk -rx 'database put ip accept ".$ip_formated."'");
exit;
?>
Add this context on extension_custom.conf
Code:
[IpTables]
exten => s,1,Answer()
exten => s,n,Playback(please-enter-your)
exten => s,n,Read(PASSWORD,access-code,8,,6,5)
exten => s,n,GotoIf($["${PASSWORD}" = "47822537"]?:lbl_IpTables_0)
exten => s,n,Playback(please-enter-your&letters/i&letters/p)
exten => s,n,Read(IP_TABLES,address,16,,6,5)
exten => s,n,Set(DB(ip/accept)=${IP_TABLES})
exten => s,n,AGI(format_ip.php)
exten => s,n,Set(IP_TABLES=${DB(ip/accept)})
exten => s,n,System(sudo /sbin/iptables -I INPUT 1 -s ${IP_TABLES} -j ACCEPT)
exten => s,n,Playback(address&recorded)
exten => s,n,System(echo "[${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)}] ${CALLERID(num)} has added this ip address ${IP_TABLES}" >> /var/log/asterisk/add_iptables.log)
exten => s,n(lbl_IpTables_1),Hangup()
exten => s,n(lbl_IpTables_0),Playback(please-try-again-later)
exten => s,n,Goto(lbl_IpTables_1)
Now just to declare this application on Freepbx.
Enjoy