Iptables e bind9 para encaminhar para o dns do google

0

Olá, eu tenho muita dificuldade em me relacionar com iptables e bind9 como meu servidor de DNS interno da rede. Está configurado para encaminhar minhas consultas para o DNS do google (8.8.8.8).

O principal problema é que não consigo configurar o iptables para permitir falar com meu dns. Minha regra principal é descartar todas as conexões INPUT e OUTPUT e permitir somente aquelas que eu necessito para alguns serviços e bind9.

Aqui está o meu iptables agora

Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:1155
ACCEPT     tcp  --  anywhere             anywhere            
ACCEPT     udp  --  anywhere             anywhere             udp spt:domain
ACCEPT     all  --  anywhere             anywhere            

Chain FORWARD (policy DROP)
target     prot opt source               destination         

Chain OUTPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere             tcp spt:1155 state RELATED,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere            
ACCEPT     udp  --  anywhere             anywhere             udp dpt:domain
ACCEPT     all  --  anywhere             anywhere            

Eu tentei usar o este usuário diz, mas sem sorte .

Também eu tentei muitas combinações permitindo a porta 53 para udp e tcp como este

sudo iptables -A INPUT -s 192.168.0.0/24 -m state --state NEW -p tcp --dport 53 -j ACCEPT
sudo iptables -A INPUT -s 192.168.0.0/24 -m state --state NEW -p udp --dport 53 -j ACCEPT

Também aqui está o que eu recebo de sudo netstat -anp | grep -e tcp -e udp

tcp        0      0 0.0.0.0:1155            0.0.0.0:*               LISTEN      969/sshd        
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1179/apache2    
tcp        0      0 192.168.0.22:53         0.0.0.0:*               LISTEN      1087/named      
tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN      1087/named      
tcp        0      0 127.0.0.1:953           0.0.0.0:*               LISTEN      1087/named      
tcp        0      0 192.168.0.22:1155       192.168.0.20:50016      ESTABLISHED 1263/sshd: giorgos 
tcp6       0      0 :::1155                 :::*                    LISTEN      969/sshd        
tcp6       0      0 :::53                   :::*                    LISTEN      1087/named      
tcp6       0      0 ::1:953                 :::*                    LISTEN      1087/named      
udp        0      0 192.168.0.22:53         0.0.0.0:*                           1087/named      
udp        0      0 127.0.0.1:53            0.0.0.0:*                           1087/named      
udp        0      0 0.0.0.0:68              0.0.0.0:*                           943/dhclient3   
udp6       0      0 :::53                   :::*                                1087/named  
    
por John Bassos 27.03.2014 / 09:45

1 resposta

0

Ok, regra iptables para isso pode ser algo parecido com isto

isso aceitará o dns req

sudo iptables -t nat -A INPUT -s 192.168.0.0/24 -m state --state NEW -p tcp --dport 53 -j ACCEPT
sudo iptables -t nat -A INPUT -s 192.168.0.0/24 -m state --state NEW -p udp --dport 53 -j ACCEPT

Isto irá criar cadeia para capturar dns req

sudo iptables -t nat -N CATCH_DNS
sudo iptables -t nat -A CATCH_DNS -p udp -m udp --dport 53 -j REDIRECT --to-ports 53
sudo iptables -t nat -A CATCH_DNS -p tcp -m tcp --dport 53 -j REDIRECT --to-ports 53

Então você pode aplicar regra no INPUT

sudo iptables -t nat -A INPUT -s 192.168.0.0/24 -j CATCH_DNS

Acho que isso funcionará:)

    
por 2707974 06.04.2014 / 10:09