Pages

Thursday, March 22, 2012

Windows DNS tools и как да ги използваме.

DNS тип заявки
А - на кое IP отговаря www.google.com.
AAAA - IPv6 версията на A.
MX - кои сървъри отговарят за e-mail-ите на google.com.
NS - кой сървъри отговарят за DNS записите на google.com.
SOA - Start of Authorite - пъртият DNS сървър отговарящ за зоната google.com.
PTR - обратен запис - на кой хост отговаря 195.177.249.170
TXT - текстов запис, може да се ползва за всичко, най-използвани са SPF TXT записи за емейл SPAM защита.

Windows nslookup.exe (start->run->cmd.exe)

Nslookup е инструмент за диагностика на DNS сървър. Освен основното което всеки администратор е ползвал C:>nslookup www.dir.bg, програмката предлага и други опции които са полезни за диагностика. Без допълнително опции nslookup изпраща запитване за A запис.

Какъв е SOA записът за зоната google.com?
C:\>nslookup -type=soa google.com
Server:  UnKnown
Address:  10.1.42.1

Non-authoritative answer:
google.com
        primary name server = ns1.google.com
        responsible mail addr = dns-admin.google.com (dns-admin@google.com)
        serial  = 2012010300
        refresh = 7200 (2 hours)
        retry   = 1800 (30 mins)
        expire  = 1209600 (14 days)
        default TTL = 300 (5 mins)

Кои DNS сървъри отговарят за зоната google.com?

C:\>nslookup -type=ns google.com
Server:  UnKnown
Address:  10.1.42.1

Non-authoritative answer:
google.com      nameserver = ns3.google.com
google.com      nameserver = ns1.google.com
google.com      nameserver = ns2.google.com
google.com      nameserver = ns4.google.com
Кой сървъри отговарят за емейла @google.com?
C:\>nslookup -type=mx google.com
Server:  UnKnown
Address:  10.1.42.1

Non-authoritative answer:
google.com      MX preference = 30, mail exchanger = alt2.aspmx.l.google.com
google.com      MX preference = 50, mail exchanger = alt4.aspmx.l.google.com
google.com      MX preference = 10, mail exchanger = aspmx.l.google.com
google.com      MX preference = 40, mail exchanger = alt3.aspmx.l.google.com
google.com      MX preference = 20, mail exchanger = alt1.aspmx.l.google.com

На кой host отговаря 216.239.32.10?
C:\>nslookup -type=ptr 216.239.32.10
Server:  UnKnown
Address:  10.1.42.1

Non-authoritative answer:
10.32.239.216.in-addr.arpa      name = ns1.google.com
IPv6 запис за google.com?
C:\>nslookup -type=aaaa google.com
Server:  UnKnown
Address:  10.1.42.1

*** No IPv6 address (AAAA) records available for google.com

Както виждаме google.com нямат IPv6 запис. (Всъщност google има AAAA запис, но връща отговор за такъв само когато е достъпван през IPv6 мрежа: http://www.google.com/intl/en/ipv6/)

IPv6 за www.netbsd.org?

C:\>nslookup -type=aaaa www.netbsd.org
Server:  UnKnown
Address:  10.1.42.1

Non-authoritative answer:
Name:    www.netbsd.org
Address:  2001:4f8:3:7:2e0:81ff:fe52:9a6b
Какъв е TXT записът за google.com? (ползва се предимно за SPF)
C:\>nslookup -type=txt google.com
Server:  UnKnown
Address:  10.1.42.1

Non-authoritative answer:
google.com      text =

"v=spf1 include:_netblocks.google.com ip4:216.73.93.70/31 ip4:216.73.93.72/31 ~all"
TXT записът е всъщност SPF запис който показва кой сървъри могат да изпращат емейли ОТ @google.com.

Non-authoritative DNS answer:
Този тип отговори идват от DNS cache сървъри.
В случая 10.1.42.1 е DNS сървър въведен в мрежовите настройки (или /etc/resolv.conf).

* клиента пита своят DNS cache server: кои сървъри отговарят за e-mail-ите на google.com.
* DNS cache сървърът намира NS записите на google.com и пита authoritative сървъра кои сървъри отговарят за e-mail-ите на google.com.
* DNS cache сървърът отговаря на клиента.
* В случая огтоворът е Non-authoritative.

C:\>nslookup -type=mx google.com
Server:  UnKnown
Address:  10.1.42.1

Non-authoritative answer:
google.com      MX preference = 50, mail exchanger = alt4.aspmx.l.google.com
google.com      MX preference = 10, mail exchanger = aspmx.l.google.com
google.com      MX preference = 40, mail exchanger = alt3.aspmx.l.google.com
google.com      MX preference = 30, mail exchanger = alt2.aspmx.l.google.com
google.com      MX preference = 20, mail exchanger = alt1.aspmx.l.google.com
Тоест отговорът не е получен от DNS сървър отговарящ за зоната google.com.

Authoritative answer:
Отговорът идва от DNS сървър отговарящ за зоната google.com. За целта предварително намираме кои DNS сървъри отговарят за google.com.

* клиента пита директно сървър отговарящ за зоната google.com
* отговорът е Authoritative
C:\>nslookup -type=ns google.com
Server:  UnKnown
Address:  10.1.42.1

Non-authoritative answer:
google.com      nameserver = ns2.google.com
google.com      nameserver = ns1.google.com
google.com      nameserver = ns3.google.com
google.com      nameserver = ns4.google.com

C:\>nslookup -type=mx google.com ns1.google.com
Server:  ns1.google.com
Address:  216.239.32.10

google.com      MX preference = 30, mail exchanger = alt2.aspmx.l.google.com
google.com      MX preference = 50, mail exchanger = alt4.aspmx.l.google.com
google.com      MX preference = 20, mail exchanger = alt1.aspmx.l.google.com
google.com      MX preference = 10, mail exchanger = aspmx.l.google.com
google.com      MX preference = 40, mail exchanger = alt3.aspmx.l.google.com
alt2.aspmx.l.google.com internet address = 74.125.127.27
alt4.aspmx.l.google.com internet address = 209.85.225.27
alt1.aspmx.l.google.com internet address = 209.85.173.27
aspmx.l.google.com      internet address = 74.125.79.27
alt3.aspmx.l.google.com internet address = 74.125.81.27

DNS client service:
Windows предлага dns client service който кешира локално dns заявките. Не е много ясно точно как работи но някои неща все пак можем да видим и сами.

C:\>ipconfig/displaydns

Windows IP Configuration

         1.0.0.127.in-addr.arpa
         ----------------------------------------
         Record Name . . . . . : 1.0.0.127.in-addr.arpa.
         Record Type . . . . . : 12
         Time To Live  . . . . : 424617
         Data Length . . . . . : 4
         Section . . . . . . . : Answer
         PTR Record  . . . . . : localhost

         vbox7.com
         ----------------------------------------
         Record Name . . . . . : vbox7.com
         Record Type . . . . . : 1
         Time To Live  . . . . : 24180
         Data Length . . . . . : 4
         Section . . . . . . . : Answer
         A (Host) Record . . . : 87.121.59.2

         www.samedeutz-fahr.com
         ----------------------------------------
         Record Name . . . . . : www.samedeutz-fahr.com
         Record Type . . . . . : 1
         Time To Live  . . . . : 86375
         Data Length . . . . . : 4
         Section . . . . . . . : Answer
         A (Host) Record . . . : 84.33.3.3


         en.wikipedia.org
         ----------------------------------------
         Record Name . . . . . : en.wikipedia.org
         Record Type . . . . . : 5
         Time To Live  . . . . : 233
         Data Length . . . . . : 4
         Section . . . . . . . : Answer
         CNAME Record  . . . . : wikipedia-lb.wikimedia.org
         .......
         .......
Това са кешираните заявки от DNS Client service.

ipconfig/flushdns

Това изтрива локалният кеш на dns client service. Понякога този service прави проблеми. Ако правите някакви промени по DNS записи, най-добре е този service да бъде спрян докато правите тестовете.

При спян DNS Client service не се кешира нищо на локалния компютър а за всяко DNS запитване се пита dns cache сървъра. При пуснат service, веднъж получен отговор от DNS cache сървъра, записът се кешира локално както се вижда и по-горе (Time To Live  . . . . : 233 примерно).

Парадоксът: Нямам интернет, но имам Skype!

Когато това нещо се получи вероятността проблемът да е в DNS сървърите които ползвате е около 99%. Как можем да го тестваме? Аз използвам публчните DNS cache сървъри на google който са достъпни за всички и най-вече се помнят много лесно. Ето ги:

google public dns cache 1: 8.8.8.8
google public dns cache 2: 8.8.4.4

Ако имате Skype, но "нямате интернет" винаги може да въведете един от тези DNS сървъри и да пробвате дали вече "имате интернет".