No Debian Jessie anterior eu poderia configurar o iptables para restringir o tráfego DNS ao meu próprio roteador (192.168.1.1):
Chain OUTBOUND (1 references)
target prot opt source destination
ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:443
ACCEPT tcp -- 192.168.1.1 0.0.0.0/0 tcp dpt:53
ACCEPT udp -- 192.168.1.1 0.0.0.0/0 udp dpt:53
LSO all -- 0.0.0.0/0 0.0.0.0/0
com o Debian Stretch não funciona mais
O Debian Stretch força a abertura da porta 53 para qualquer lugar ou o navegador e outros softwares não funcionam. Estou preocupado com o fato de permitir consultas ocultas de DNS ao terceiro software.
Peço para saber o motivo pelo qual essa regra simples do iptables não funciona no Stretch.
Editar :
root:# cat /etc/resolv.conf
# Generated by NetworkManager
search 192.168.1.1
nameserver 192.168.1.1
root:# ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.424 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.298 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.494 ms
root:# tcpdump -nt -i eth0 udp port 53
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
^C
0 packets captured
root:# dig 192.168.1.1
^C
sem resposta
do lado do roteador:
root@router:~ # dig 192.168.1.103
; <<>> DiG 9.2.4 <<>> 192.168.1.103
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31716
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;192.168.1.103. IN A
;; ANSWER SECTION:
192.168.1.103. 0 IN A 192.168.1.103
;; Query time: 1 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Oct 17 19:07:32 2018
;; MSG SIZE rcvd: 47
root@router:~ # ping 192.168.1.103
PING 192.168.1.103 (192.168.1.103) 56(84) bytes of data.
64 bytes from 192.168.1.103: icmp_seq=0 ttl=64 time=0.257 ms
64 bytes from 192.168.1.103: icmp_seq=1 ttl=64 time=0.222 ms
64 bytes from 192.168.1.103: icmp_seq=2 ttl=64 time=0.331 ms
^C
--- 192.168.1.103 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.222/0.270/0.331/0.045 ms, pipe 2