This Gist contains my IPTables rules for securing the Asterisk VoIP server. The "string" module is used to identify legitimate users and block attackers.
Learn how to set up your personal VoIP server
↓ ↓ ↓ Scroll down for the IPTables rules ↓ ↓ ↓
#!/bin/bash | |
### VARIABLES ### \ | |
EMAIL="" | |
SERVER=$(hostname) | |
MYSQL_CHECK=$(mysql --login-path=mysql_login -e "SHOW VARIABLES LIKE '%version%';" || echo 1) | |
STATUS_LINE=$(mysql --login-path=mysql_login -e "SHOW SLAVE STATUS\G")"1" | |
LAST_ERRNO=$(grep "Last_Errno" <<< "$STATUS_LINE" | awk '{ print $2 }') | |
SECONDS_BEHIND_MASTER=$( grep "Seconds_Behind_Master" <<< "$STATUS_LINE" | awk '{ print $2 }') | |
IO_IS_RUNNING=$(grep "Slave_IO_Running:" <<< "$STATUS_LINE" | awk '{ print $2 }') |
#!/bin/bash | |
# replicate_db.sh (c) by Niraj Shah | |
# replicate_db.sh is licensed under a | |
# Creative Commons Attribution-ShareAlike 4.0 International License. | |
# You should have received a copy of the license along with this | |
# work. If not, see <http://creativecommons.org/licenses/by-sa/4.0/>. | |
# https://www.webniraj.com/2017/01/13/replicating-a-remote-mysql-database-to-local-environment-server/ |
USE asterisk; | |
GRANT ALL PRIVILEGES ON asterisk.* TO 'asterisk'@'localhost' IDENTIFIED BY 'change_me'; | |
FLUSH PRIVILEGES; | |
CREATE TABLE IF NOT EXISTS cdr ( | |
id BIGINT(20) NOT NULL AUTO_INCREMENT, | |
accountcode VARCHAR(30), | |
src VARCHAR(64), | |
dst VARCHAR(64), | |
dcontext VARCHAR(32), | |
clid VARCHAR(64), |
This Gist contains my IPTables rules for securing the Asterisk VoIP server. The "string" module is used to identify legitimate users and block attackers.
Learn how to set up your personal VoIP server
↓ ↓ ↓ Scroll down for the IPTables rules ↓ ↓ ↓
#!/bin/bash | |
### VARIABLES ### \ | |
EMAIL="" | |
SERVER=$(hostname) | |
MYSQL_CHECK=$(mysql -e "SHOW VARIABLES LIKE '%version%';" || echo 1) | |
LAST_ERRNO=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G" | grep "Last_Errno" | awk '{ print $2 }') | |
SECONDS_BEHIND_MASTER=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G"| grep "Seconds_Behind_Master" | awk '{ print $2 }') | |
IO_IS_RUNNING=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G" | grep "Slave_IO_Running" | awk '{ print $2 }') | |
SQL_IS_RUNNING=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G" | grep "Slave_SQL_Running" | awk '{ print $2 }') |