Entramos en materia, iptables es un firewall tipico de instalaciones linux:
1.- Instalacion usando yum:
yum install iptables
2.- Crear un archivo de texto de configuracion (usando nano o vim):
nano /etc/sysconfig/iptables
# By default drop all incoming and forwarded traffic
# Allow all outgoing traffic
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
# Puerto 80 http para los diferentes servicios web que podamos tener
-A INPUT -p udp –dport 80 -j ACCEPT
# Puerto Protocolo Dundi
-A INPUT -p udp –dport 4520 -j ACCEPT
# Puerto IAX
-A INPUT -p udp –dport 4569 -j ACCEPT
# Puerto SIP
-A INPUT -p udp –dport 5060 -j ACCEPT
# Puertos RTP media (este rango de puertos luego debemos indicarselo al asterisk)
-A INPUT -p udp –dport 10000:20000 -j ACCEPT
# Allow incoming SSH (el 22 es el puerto por default)
-A INPUT -p tcp –dport xxxx -j ACCEPT
# Allow ping
-A INPUT -p icmp –icmp-type ping -j ACCEPT
# Allow local traffic
-A INPUT -i lo -j ACCEPT
# Allow ping
-A INPUT -p icmp –icmp-type ping -j ACCEPT
COMMIT
Importante es abrir el puerto xxxx de ssh, (22 por defualt)
Guardamos el archivo y debemos reiniciar iptables:
service iptables restart
Aparecera:
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: [ OK ]
Applying iptables firewall rules: [ OK ]
Chequeo general:
iptables -L
Para terminar tenemos que decirle a asterisk que use los puertos desde 10000 hasta 20000 para el protocolo RTP:
abrimos el archivo
vim /etc/asterisk/rtp.conf
quitamos (si lo hay) el punto y coma antes de [general]
En rtpstart ponemos 10000 y en rtpend ponemos 20000
rtpstart=10000
rtpend=20000
Guardar el archivo y reiniciar asterisk:
/etc/init.d/asterisk reload