IPTables não está fazendo o que solicitei

IPTables não está fazendo o que solicitei

A comunidade aqui é incrível!

Eu tenho um roteador sem fio ASUS 3100 e cerca de 4 câmeras IP. No meu roteador antigo, era fácil bloquear o tráfego de saída para que eu pudesse ter certeza de que as câmeras não estavam "ligando para casa". Quero fazer a mesma coisa com este roteador, então decidi primeiro usar a ferramenta de encaminhamento de porta e depois comecei a procurar IPTABLES. Não sei se isso é um problema para o asuswrt-merlin usar o encaminhamento de porta na ferramenta de administração dos roteadores e no iptables. Eu suspeitaria que não...certo?

Meu gol:

  1. Por padrão, bloqueie o tráfego de entrada e saída para 192.168.1.0/29
  2. Exceção: Quero abrir 120:130, MAS apenas para alguns IPs confiáveis ​​(trabalho ou casa de amigos). Digamos que esses IPs sejam 150.150.150.150 e 250.250.250.0/24 (eu uso um navegador para acessar essas portas, o que provavelmente não importa), então se eu quisesse acessar a CÂMERA #2 seria DDNS.dns.com:121
  3. Exceção: As câmeras enviam e-mails via SMTPS (porta 465), então quero abri-la para que possa enviar os e-mails.

Não quero bloquear ENTRADAS/SAÍDAS, pois tenho algumas coisas de IoT que se comunicam em outro lugar, então não quero alterar a política padrão para bloquear isso. A menos que eu esteja entendendo mal como isso funciona.

Atualizei o roteador com o Asuswrt-Merlin mais recente e ativei os scripts personalizados JFFS. Criei um arquivo /jffs/scripts/chamado firewall-start. Editei o arquivo começando com shebang e adicionei algumas regras (voltarei a isso mais tarde). Eu usei service restart_firewall. O problema em que estou me metendo é que não estou obtendo os resultados apropriados e é bem possível que esteja escrevendo as regras e/ou talvez a ordem erradas.

Eu tentei o iptables forward, tentei o iptables INPUT & OUTPUT e tentei uma combinação de "INSERT" / "APPEND" e por algum motivo estranho ele irá BLOQUEAR tudo ou deixá-lo ABERTO completamente. Nunca segue meu objetivo final. Tenho certeza de que tem a ver com alguma ordem ou regras padrão para FORWARD ou INPUT ou OUTPUT, mas simplesmente não consigo entender.

Eu inseri as regras uma de cada vez também. Algo simples para começar.

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

Isso derruba tudo. Às vezes é complicado porque se eu tentar canyouseeme.org e ele disser que foi bem-sucedido, coloque o código e ele ainda diz que foi bem-sucedido. Às vezes diz que falhou (o que significa que caiu), então às vezes é isso que encontro, mas parece que talvez seja um problema não relacionado. Então eu digo para mim mesmo ok, isso funciona. agora vamos adicionar uma regra INSERT DEPOIS disso porque obviamente INSERT vai para o topo, então adicionei após o código acima com isto:

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

Então, com esses dois no arquivo. Eu libero o iptables e reinicio o serviço de inicialização do firewall para que ele adquira as novas regras. Eu uso iptables -Le vejo que está na ordem certa. Teste recarregando a página ddns.dns.com:121 e nada. Não carregará. É algum cache? isso precisa de tempo? Às vezes espero 5 minutos e ainda nada. Eu uso canyouseeme.org novamente e ainda diz que falhou no último código DROP.

Preciso de alguns especialistas para me ajudar. Aqui está meu iptable existente a partir de agora:

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

Desde já, obrigado!

informação relacionada