IPTables no hace lo que solicité

IPTables no hace lo que solicité

¡La comunidad aquí es increíble!

Tengo un enrutador inalámbrico ASUS 3100 y aproximadamente 4 cámaras IP. En mi antiguo enrutador era fácil bloquear el tráfico saliente para poder asegurarme de que las cámaras no estuvieran "llamando a casa". Quiero hacer lo mismo con este enrutador, así que primero decidí usar la herramienta de reenvío de puertos y luego comencé a buscar IPTABLES. No sé si esto es un problema para que asuswrt-merlin use el reenvío de puertos en la herramienta de administración del enrutador y en iptables. Sospecho que no... ¿verdad?

Mi meta:

  1. De forma predeterminada, bloquea el tráfico saliente y entrante para 192.168.1.0/29
  2. Excepción: Quiero abrir 120:130 PERO solo para un puñado de IP confiables (trabajo o casa de un amigo). Digamos que esas IP son 150.150.150.150 y 250.250.250.0/24 (uso un navegador para acceder a estos puertos, pero eso probablemente no importe de todos modos), así que si quisiera acceder a la CÁMARA n.° 2 sería DDNS.dns.com:121
  3. Excepción: Las cámaras envían correos electrónicos a través de SMTPS (puerto 465), así que quiero abrir eso para que pueda enviar los correos electrónicos.

No quiero bloquear las ENTRADAS/SALIDAS ya que tengo algunas cosas de IoT que se comunican en otro lugar, por lo que no quiero cambiar la política predeterminada para bloquear eso. A menos que no entienda bien cómo funciona.

Actualicé el enrutador con la última versión de Asuswrt-Merlin y activé los scripts personalizados JFFS. Creé un archivo /jffs/scripts/llamado firewall-start. Edité el archivo comenzando con shebang y agregué algunas reglas (volveré a esto más adelante). Solía service restart_firewall​​. El problema en el que me estoy metiendo es que no estoy obteniendo los resultados adecuados y es muy posible que esté escribiendo mal las reglas y/o quizás el orden.

Probé iptables forward, probé iptables INPUT & OUTPUT, y probé una combinación de "INSERT" / "APPEND" y por alguna extraña razón BLOQUEArá todo o lo dejará ABIERTO completamente. Nunca sigue mi objetivo final. Estoy seguro de que tiene que ver con algún orden o reglas predeterminadas para ADELANTE, ENTRADA o SALIDA, pero no puedo entenderlo.

También inserté las reglas una a la vez. Algo sencillo para empezar.

iptables -I FORWARD -d 192.168.1.0/29 -p tcp --dport 17111 -j DROP

Esto lo deja caer. A veces es complicado porque si pruebo canyouseeme.org y dice exitoso, ingrese el código, todavía dice exitoso. A veces dice que falló (lo que significa que se cayó), así que a veces eso es lo que encuentro, pero parece que tal vez sea un problema no relacionado. Entonces me digo a mí mismo, está bien, eso funciona. ahora agreguemos una regla INSERTAR DESPUÉS de esto porque obviamente INSERTAR va a la parte superior, así que agregué después del código anterior con esto:

iptables -I FORWARD -s myworkip -d 192.168.1.0/29 -p tcp --dport 121 -j ACCEPT

Entonces con esos dos en el expediente. Limpio las iptables y luego reinicio el servicio de inicio del firewall para que adquiera las nuevas reglas. Yo uso iptables -Lveo que está en el orden correcto. Pruébelo recargando la página web ddns.dns.com:121 y nada. No se cargará. ¿Es algún almacenamiento en caché? ¿Necesita tiempo? A veces espero 5 minutos y nada. Utilizo canyouseeme.org nuevamente y todavía dice error desde el último código DROP.

Necesito algunos expertos que me ayuden. Aquí está mi iptable existente en este momento:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination
DROP       icmp --  anywhere             anywhere             icmp echo-request
ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
DROP       all  --  anywhere             anywhere             state INVALID
PTCSRVWAN  all  --  anywhere             anywhere
PTCSRVLAN  all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere             state NEW
ACCEPT     all  --  anywhere             anywhere             state NEW
OVPN       all  --  anywhere             anywhere             state NEW
ACCEPT     udp  --  anywhere             anywhere             udp spt:bootps dpt:bootpc
INPUT_ICMP  icmp --  anywhere             anywhere
DROP       all  --  anywhere             anywhere

Chain FORWARD (policy DROP)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
other2wan  all  --  anywhere             anywhere
DROP       all  --  anywhere             anywhere             state INVALID
ACCEPT     all  --  anywhere             anywhere
NSFW       all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere             ctstate DNAT
OVPN       all  --  anywhere             anywhere             state NEW
ACCEPT     all  --  anywhere             anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain ACCESS_RESTRICTION (0 references)
target     prot opt source               destination

Chain FUPNP (0 references)
target     prot opt source               destination

Chain INPUT_ICMP (1 references)
target     prot opt source               destination
RETURN     icmp --  anywhere             anywhere             icmp echo-request
RETURN     icmp --  anywhere             anywhere             icmp timestamp-request
ACCEPT     icmp --  anywhere             anywhere

Chain NSFW (1 references)
target     prot opt source               destination

Chain OVPN (2 references)
target     prot opt source               destination

Chain PControls (0 references)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere

Chain PTCSRVLAN (1 references)
target     prot opt source               destination

Chain PTCSRVWAN (1 references)
target     prot opt source               destination

Chain SECURITY (0 references)
target     prot opt source               destination
RETURN     tcp  --  anywhere             anywhere             tcpflags: FIN,SYN,RST,ACK/SYN limit: avg 1/sec burst 5
DROP       tcp  --  anywhere             anywhere             tcpflags: FIN,SYN,RST,ACK/SYN
RETURN     tcp  --  anywhere             anywhere             tcpflags: FIN,SYN,RST,ACK/RST limit: avg 1/sec burst 5
DROP       tcp  --  anywhere             anywhere             tcpflags: FIN,SYN,RST,ACK/RST
RETURN     icmp --  anywhere             anywhere             icmp echo-request limit: avg 1/sec burst 5
DROP       icmp --  anywhere             anywhere             icmp echo-request
RETURN     all  --  anywhere             anywhere

Chain default_block (0 references)
target     prot opt source               destination

Chain logaccept (0 references)
target     prot opt source               destination
LOG        all  --  anywhere             anywhere             state NEW LOG level warning tcp-sequence tcp-options ip-options prefix "ACCEPT "
ACCEPT     all  --  anywhere             anywhere

Chain logdrop (0 references)
target     prot opt source               destination
LOG        all  --  anywhere             anywhere             state NEW LOG level warning tcp-sequence tcp-options ip-options prefix "DROP "
DROP       all  --  anywhere             anywhere

Chain other2wan (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere
DROP       all  --  anywhere             anywhere

¡Gracias de antemano!

información relacionada