This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
voice:pbx:security [2013/10/01 09:22] gcooper |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== PBX Security ====== | ||
- | :!: Only open the required ports and no more to minimize your ' | ||
- | |||
- | ===== SELinux ===== | ||
- | |||
- | SELinux generally gets in the way, so it is often disabled: | ||
- | |||
- | < | ||
- | setenforce 0 | ||
- | |||
- | vi / | ||
- | |||
- | SELINUX=disabled | ||
- | </ | ||
- | |||
- | ===== Firewall on the PBX Itself ===== | ||
- | |||
- | Some or all of the following ports may need to be opened: | ||
- | |||
- | ^Protocol | ||
- | |TCP | ||
- | |TCP | ||
- | |TCP | ||
- | |TCP | ||
- | |UDP | ||
- | |UDP | ||
- | |UDP | ||
- | |||
- | :!: Two firewall options are Arno's Firewall or the built-in IPtables. | ||
- | |||
- | ==== Arno's Firewall ==== | ||
- | |||
- | Arno's Firewall is a light weight and comprehensive firewall based on '' | ||
- | |||
- | See also **[[networking: | ||
- | |||
- | ==== IPtables ==== | ||
- | |||
- | If you plan to use TFTP or FTP on the PBX itself, load a couple of kernel modules and make them survive reboots: | ||
- | |||
- | < | ||
- | modprobe ip_conntrack_tftp | ||
- | modprobe ip_conntrack_ftp | ||
- | depmod -a | ||
- | </ | ||
- | |||
- | Now we modify the default firewall rules in a way that survives reboots. | ||
- | |||
- | Add these lines right after the ' | ||
- | |||
- | < | ||
- | vi / | ||
- | |||
- | -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT | ||
- | -A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT | ||
- | -A INPUT -m state --state NEW -m udp -p udp --dport 69 -j ACCEPT | ||
- | -A INPUT -m state --state NEW -m udp -p udp --dport 4569 -j ACCEPT | ||
- | -A INPUT -m state --state NEW -m udp -p udp --dport 5060:5061 -j ACCEPT | ||
- | -A INPUT -m state --state NEW -m udp -p udp --dport 10000:20000 -j ACCEPT | ||
- | |||
- | service iptables reload | ||
- | |||
- | iptables -nL | ||
- | </ | ||
- | |||
- | ===== Force SSL ===== | ||
- | |||
- | First, make sure the '' | ||
- | |||
- | Create an '' | ||
- | |||
- | < | ||
- | vi / | ||
- | |||
- | # Force SSL | ||
- | RewriteEngine On | ||
- | RewriteCond %{HTTPS} off | ||
- | RewriteRule (.*) https:// | ||
- | |||
- | service httpd restart | ||
- | </ | ||
- | |||
- | ===== MySQL Root Password ===== | ||
- | |||
- | < | ||
- | mysqladmin -u root password newpassword | ||
- | </ | ||
- | |||
- | or | ||
- | |||
- | < | ||
- | mysqladmin -u root -p ' | ||
- | </ | ||
- | |||
- | ===== Fail2Ban ===== | ||
- | |||
- | Fail2Ban is a superior tool that monitors various log files looking for brute force attacks. | ||
- | |||
- | See **[[networking: | ||
- | |||
- | For a base CentOS 6 box, after installing Fail2Ban via the EPEL repo, you can just copy and paste the following in one go to get a basic Fail2Ban installation set up for your PBX: | ||
- | |||
- | < | ||
- | cat << EOF >> / | ||
- | # Fail2Ban local configuration file | ||
- | # | ||
- | # This file overrides the fail2ban.conf file | ||
- | |||
- | [Definition] | ||
- | logtarget = / | ||
- | |||
- | EOF | ||
- | |||
- | cat << EOF >> / | ||
- | # Fail2Ban local configuration file | ||
- | # | ||
- | # This file overrides the jail.conf file | ||
- | |||
- | [DEFAULT] | ||
- | ignoreip = 127.0.0.1 209.193.64.0/ | ||
- | bantime | ||
- | findtime | ||
- | maxretry = 3 | ||
- | backend = auto | ||
- | |||
- | |||
- | [asterisk-iptables] | ||
- | enabled | ||
- | filter | ||
- | action | ||
- | # | ||
- | logpath | ||
- | maxretry = 5 | ||
- | bantime = 600 | ||
- | |||
- | [ssh-iptables] | ||
- | enabled | ||
- | filter | ||
- | action | ||
- | # | ||
- | logpath | ||
- | maxretry = 3 | ||
- | |||
- | [apache-tcpwrapper] | ||
- | enabled | ||
- | filter | ||
- | action | ||
- | # | ||
- | logpath | ||
- | maxretry = 3 | ||
- | |||
- | [vsftpd-iptables] | ||
- | enabled | ||
- | filter | ||
- | action | ||
- | # | ||
- | logpath | ||
- | maxretry = 3 | ||
- | bantime | ||
- | |||
- | [apache-badbots] | ||
- | enabled | ||
- | filter | ||
- | action | ||
- | # | ||
- | logpath | ||
- | bantime | ||
- | maxretry = 1 | ||
- | |||
- | EOF | ||
- | |||
- | cat << EOF >> / | ||
- | # Fail2Ban configuration file | ||
- | # | ||
- | # Asterisk Filter - / | ||
- | |||
- | [INCLUDES] | ||
- | |||
- | # Read common prefixes. If any customizations available -- read them from | ||
- | # common.local | ||
- | #before = common.conf | ||
- | |||
- | [Definition] | ||
- | |||
- | #_daemon = asterisk | ||
- | |||
- | # Option: | ||
- | # Notes.: | ||
- | # host must be matched by a group named " | ||
- | # be used for standard IP/hostname matching and is only an alias for | ||
- | # (?::: | ||
- | # Values: | ||
- | # | ||
- | |||
- | failregex = Registration from ' | ||
- | Registration from ' | ||
- | Registration from ' | ||
- | Registration from ' | ||
- | Registration from ' | ||
- | NOTICE.* < | ||
- | NOTICE.* .*: No registration for peer ' | ||
- | NOTICE.* .*: Host < | ||
- | VERBOSE.* logger.c: -- .*IP/< | ||
- | |||
- | # Option: | ||
- | # Notes.: | ||
- | # Values: | ||
- | # | ||
- | ignoreregex = | ||
- | |||
- | EOF | ||
- | |||
- | service fail2ban restart | ||
- | </ | ||
- | |||
- | ===== Digium Recommendations ===== | ||
- | |||
- | Seven Easy Steps to Better SIP Security on Asterisk: | ||
- | |||
- | - Don’t accept SIP authentication requests from all IP addresses. Use the '' | ||
- | - Set '' | ||
- | - Use STRONG passwords for SIP entities. This is probably the most important step you can take. Don’t just concatenate two words together and suffix it with " | ||
- | - Block your AMI manager ports. Use '' | ||
- | - Allow only one or two calls at a time per SIP entity, where possible. At the worst, limiting your exposure to toll fraud is a wise thing to do. This also limits your exposure when legitimate password holders on your system lose control of their pass-phrase, | ||
- | - Make your SIP usernames different than your extensions. While it is convenient to have extension " | ||
- | - Ensure your '' | ||
- | - See more at: http:// |