FortiGateGuías técnicas
Troubleshooting de DNS en Fortigate
Todos conocemos la importancia de los procesos de resolución de nombres y la cantidad de problemas que puede ocasionar una mala configuración o gestión de estos tráficos.
Fortigate utiliza DNS incluso para varias de sus propias funciones incluyendo comunicación con Fortiguard, envíos de mails de alertas o bloqueo URL (utilizando FQDN). Es por esto que es importante conocer como han ido variando los comandos de diagnostico de DNS que incluye Fortigate a lo largo de las versiones y que es posible lograr con estos comandos.
En versiones anteriores a FortiOS 3.0 MR6 el troubleshooting de DNS se realizaba vía haproxy:
diag debug haproxy dump
DNS proxy cache dump:
Cached [0x8c15c18]: Questions in query:
QR: update.fortiguard.net.
Cached [0x8c156d8]: Questions in query:
QR: www.fortinet.com.
—End of DNS proxy cache dump—
diag debug haproxy fqdndump
FQDN entry dump:
www.fortinet.com: ID(107) REF(1) EXPIRE(1224623673, ttl 3600) VD(0, ref 1)
—End of FQDN entry dump (total 1)–
Desde FOS 3.0 MR7 la via para obtener diferente tipo de información acerca de DNS paso al dnsproxy:
diag test application dnsproxy ?
1. Clear dns cache
2. Show stats
3. Dump DNS setting
4. Reload FQDN
5. Requery FQDN
6. Dump FQDN
Por ejemplo para borrar la cache DNS del Fortigate utilizaríamos:
diag test application dnsproxy 1
Para ver la configuración sería:
diag test application dnsproxy 3
Management: vd=root, id=0, master=1:1
DNS server 0: x.x.x.x:53
DNS server 1: x.x.x.x:53
DNS server 2: x.x.x.x:53
DNS server 3: x.x.x.x:53
DNS_CACHE: hash-size=2048, ttl=1800, min-ttl=60, max-num=5000
DNS FD: mgmt_s=7, mgmt_c=8, mgmt_c2=9, ha_s=5 ha_c=6 unix_s=10, unix_nb_s=11, unix_nc_s=12
relay dmz in root: fd=13
relay internal in root: fd=14
dns_out_sock=8, mgmt_recreate_sock=0 mgmt_switched=0, jiffies=91669
FQDN: hash_size=1024, current_query=1024
DNS FD: tcp_s=15
Existiría otra forma alternativa via CLI de ver como se resuelve una petición concreta, en el ejemplo www.fortinet.com. Primeramente habilitaríamos el modo debug del dnsproxy de la siguiente manera:
diag debug application dnsproxy -1
Y luego lanzaríamos, por ejemplo, un ping contra www.fortinet.com:
execute ping www.fortinet.com
unix_receive_request()-521
handle_dns_request()-378: pktlen=32, qr=0
dns_forward_request()-303
dns_forward_request()-316: Send 32B to x.y.z.t:53 via fd=8
mgmt_receive_response()-504
mgmt_receive_response()-510: len=116, addr=x.y.z.t:53, addrlen=16
handle_dns_response()-423
dns_set_min_ttl()-153: QR: www.fortinet.com
dns_set_min_ttl()-161: Offset of 1st RR: 32 Number of RR’s: 5
dns_set_min_ttl()-171: RR TTL: 43200
dns_set_min_ttl()-171: RR TTL: 277
dns_set_min_ttl()-171: RR TTL: 277
dns_set_min_ttl()-171: RR TTL: 277
dns_set_min_ttl()-171: RR TTL: 277
dns_cache_response()-229: Min ttl = 277
dns_forward_response()-330
dns_forward_response()-334: Send 32B via fd=10
Con “diag debug disable” deshabilitaríamos el modo debug activo del dnsproxy.
En versiones 5.4 se añadieron nuevas posibilidades que se podrían en práctica igual que las arriba indicadas:
diag test application dnsproxy ?
- Clear DNS cache
- Show stats
- Dump DNS setting
- Reload FQDN
- Requery FQDN
- Dump FQDN
- Dump DNS cache
- Dump DNS DB
- Reload DNS DB
- Dump secure DNS policy/profile
- Dump Botnet domain
- Reload Secure DNS setting
- Show Hostname cache
- Clear Hostname cache
- DNS debug bit mask
Y en 6.0 se añadió aun más infomación también resultante de nuevas características de la versión igual que paso con 5.4:
diag test application dnsproxy ?
- Clear DNS cache
- Show stats
- Dump DNS setting
- Reload FQDN
- Requery FQDN
- Dump FQDN
- Dump DNS cache
- Dump DNS DB
- Reload DNS DB
- Dump secure DNS policy/profile
- Dump Botnet domain
- Reload Secure DNS setting
- Show Hostname cache
- Clear Hostname cache
- Show SDNS rating cache
- Clear SDNS rating cache
- DNS debug bit mask
En 6.2 se ha mejorado aun más las posibilidades del comando:
diagnose test application dnsproxy
worker idx: 0
- Clear DNS cache
- Show stats
- Dump DNS setting
- Reload FQDN
- Requery FQDN
- Dump FQDN
- Dump DNS cache
- Dump DNS DB
- Reload DNS DB
- Dump secure DNS policy/profile
- Dump Botnet domain
- Reload Secure DNS setting
- Show Hostname cache
- Clear Hostname cache
- Show SDNS rating cache
- Clear SDNS rating cache
- DNS debug bit mask
- Restart dnsproxy worker
**En algunas versiones la manera de ver las posibilidades del comando es utilizando una interrogación al final del comando (?) en otras en simplemente presionando enter (intro).