From e30c62ee2f296d90a067ef20384b204a17939712 Mon Sep 17 00:00:00 2001 From: "enrique.lara" Date: Wed, 19 Aug 2026 20:59:45 +0000 Subject: [PATCH] flush_firewall.sh ***NOTA*** Editar el archivo e indicar el puerto SSH en el apartado #5 --- flush_firewall.sh | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 flush_firewall.sh diff --git a/flush_firewall.sh b/flush_firewall.sh new file mode 100644 index 0000000..39a9721 --- /dev/null +++ b/flush_firewall.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# 1. Políticas por defecto +iptables -P INPUT ACCEPT +iptables -P FORWARD ACCEPT +iptables -P OUTPUT ACCEPT + +# 2. Limpieza total de reglas y cadenas personalizadas +iptables -F +iptables -X +iptables -Z + +# 3. Permitir tráfico de Loopback y conexiones ya establecidas +iptables -A INPUT -i lo -j ACCEPT +iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT + +# 4. ICMP (Ping) +iptables -A INPUT -p icmp -j ACCEPT + +# 5. SSH (Puerto personalizado actual 22171 y estándar 22 por seguridad) +iptables -A INPUT -p tcp --dport INDICAR-PORT -j ACCEPT +iptables -A INPUT -p tcp --dport 22 -j ACCEPT + +# 6. REGLAS SEGÚN PLANTILLA HETZNER (FIREWALL-PBX-V2) + +# ADMINISTRACION SOLO OFICINA (Sustituye la IP si cambia) +iptables -A INPUT -s 186.96.24.214 -p tcp -j ACCEPT + +# SERVICIO ZABBIX +iptables -A INPUT -s 5.161.85.196 -p tcp -j ACCEPT + +# TELINTA DATA NETWORK +iptables -A INPUT -s 208.89.106.17 -p udp -j ACCEPT + +# SERVIDOR VPN (OPEN VPN) +iptables -A INPUT -s 2.29.9.161 -j ACCEPT + +# RANGO EXTENSIONES PJSIP/SIP (UDP 5060:5066) +iptables -A INPUT -p udp --dport 5060:5066 -j ACCEPT + +# TLS (TCP 5061) +iptables -A INPUT -p tcp --dport 5061 -j ACCEPT + +# RTP (UDP 10000:20000) +iptables -A INPUT -p udp --dport 10000:20000 -j ACCEPT + +# 7. Regla por defecto al final (Bloquear todo lo demás) +iptables -A INPUT -j REJECT --reject-with icmp-host-prohibited \ No newline at end of file