Não é possível conectar as portas encaminhadas do ufw / iptables pelo ip externo

1

Eu estava encaminhando minha porta 25 para 53525 no meu servidor usando a configuração ufw e iptable.

É testable port pelo comando telnet, por isso tentei testá-lo.

A conexão está bem na minha porta 25 no host local, mas não consigo conectar de computadores externos.

Eu verifiquei o resultado netstat -ntlp , minha porta 25 não está listada. mas a porta 53525 está listada.

Anexe minha configuração do ufw / iptables. Por favor ajude.

Arquivo: /etc/ufw/before.rules

*nat
:PREROUTING ACCEPT [0:0]
-A OUTPUT -p tcp --dport 25 -j REDIRECT --to-port 53525
-A OUTPUT -p tcp --dport 143 -j REDIRECT --to-port 54143
-A OUTPUT -p tcp --dport 445 -j REDIRECT --to-port 54445
-A OUTPUT -p tcp --dport 139 -j REDIRECT --to-port 54139
-A OUTPUT -p tcp --dport 173 -j REDIRECT --to-port 54173
-A OUTPUT -p tcp --dport 138 -j REDIRECT --to-port 54138
-A OUTPUT -p tcp --dport 1025 -j REDIRECT --to-port 53525
COMMIT

Comando: iptables -t nat -L

Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:netbios-dgm redir ports 54138
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:173 redir ports 54173
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:netbios-ssn redir ports 54139
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:microsoft-ds redir ports 54445
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:imap2 redir ports 54143
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:smtp redir ports 53525
DOCKER     all  --  anywhere             anywhere             ADDRTYPE match dst-type LOCAL
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:imap2 redir ports 54143
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:smtp redir ports 53525
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:microsoft-ds redir ports 54445
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:netbios-ssn redir ports 54139
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:173 redir ports 54173
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:netbios-dgm redir ports 54138

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:netbios-dgm redir ports 54138
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:173 redir ports 54173
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:netbios-ssn redir ports 54139
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:microsoft-ds redir ports 54445
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:imap2 redir ports 54143
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:smtp redir ports 53525
DOCKER     all  --  anywhere            !loopback/8           ADDRTYPE match dst-type LOCAL
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:smtp redir ports 53525
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:smtp redir ports 53525
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:imap2 redir ports 54143
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:microsoft-ds redir ports 54445
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:netbios-ssn redir ports 54139
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:173 redir ports 54173
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:netbios-dgm redir ports 54138
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:smtp redir ports 53525
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:imap2 redir ports 54143
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:microsoft-ds redir ports 54445
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:netbios-ssn redir ports 54139
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:173 redir ports 54173
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:netbios-dgm redir ports 54138
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:smtp redir ports 53525
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:imap2 redir ports 54143
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:microsoft-ds redir ports 54445
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:netbios-ssn redir ports 54139
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:173 redir ports 54173
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:netbios-dgm redir ports 54138
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:1025 redir ports 53525
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:smtp redir ports 53525
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:imap2 redir ports 54143
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:microsoft-ds redir ports 54445
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:netbios-ssn redir ports 54139
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:173 redir ports 54173
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:netbios-dgm redir ports 54138
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:1025 redir ports 53525

Comando: ufw status

22                         ALLOW       Anywhere
80                         ALLOW       Anywhere
25                         ALLOW       Anywhere
110                        ALLOW       Anywhere
143                        ALLOW       Anywhere
443                        ALLOW       Anywhere
465                        ALLOW       Anywhere
587                        ALLOW       Anywhere
993                        ALLOW       Anywhere
995                        ALLOW       Anywhere
4190                       ALLOW       Anywhere
3389                       ALLOW       Anywhere
8083                       ALLOW       Anywhere
22 (v6)                    ALLOW       Anywhere (v6)
80 (v6)                    ALLOW       Anywhere (v6)
25 (v6)                    ALLOW       Anywhere (v6)
110 (v6)                   ALLOW       Anywhere (v6)
143 (v6)                   ALLOW       Anywhere (v6)
443 (v6)                   ALLOW       Anywhere (v6)
465 (v6)                   ALLOW       Anywhere (v6)
587 (v6)                   ALLOW       Anywhere (v6)
993 (v6)                   ALLOW       Anywhere (v6)
995 (v6)                   ALLOW       Anywhere (v6)
4190 (v6)                  ALLOW       Anywhere (v6)
3389 (v6)                  ALLOW       Anywhere (v6)
8083 (v6)                  ALLOW       Anywhere (v6)
    
por user115930 10.03.2017 / 10:09

1 resposta

0

Eu encontrei a solução.

Ao fazer o redirecionamento de portas no UFW, você precisa adicionar uma porta de destino para permitir a regra.

Por exemplo, se você quiser encaminhar a porta de origem 22 para a porta de destino 1922,

você tem que executar o comando 'ufw allow 22' e 'ufw allow port 1922'.

Se não foi a porta de código aberto ou porta de destinação, o pré-roteamento não está funcionando.

    
por user115930 12.05.2017 / 16:21