Host команда (Linux), тествайте вашия DNS

15.09.2020 70 0

Продължаваме нашата серия от статии с практична насоченост относно различен софтуер за диагностика на мрежи. Днес е ред на Host командата (Linux Host Command). Може да я ползвате вместо nslookup на вашия Linux компютър.

Как да видя синтаксиса на host командата?

За да видите синтаксиса на host командата, следвайте тези стъпки:

  1. Отворете Терминала (Terminal)
  2. Напишете host
  3. Натиснете Enter

Готово. Сега ще видите следното съобщение:

linux@linux:~$ host
Usage: host [-aCdilrTvVw] [-c class] [-N ndots] [-t type] [-W time]
            [-R number] [-m flag] hostname [server]
       -a is equivalent to -v -t ANY
       -c specifies query class for non-IN data
       -C compares SOA records on authoritative nameservers
       -d is equivalent to -v
       -i IP6.INT reverse lookups
       -l lists all hosts in a domain, using AXFR
       -m set memory debugging flag (trace|record|usage)
       -N changes the number of dots allowed before root lookup is done
       -r disables recursive processing
       -R specifies number of retries for UDP packets
       -s a SERVFAIL response should stop query
       -t specifies the query type
       -T enables TCP/IP mode
       -v enables verbose output
       -V print version number and exit
       -w specifies to wait forever for a reply
       -W specifies how long to wait for a reply
       -4 use IPv4 query transport only
       -6 use IPv6 query transport only

Какви опции има хост командата?

Може да видите опциите, следвайки същите стъпки. Това са опциите, които ще видите:

Option Description
-a Same as -v -t ANY, shows all records
-c Non-In data specific query class
-d Equivalent to -v
-i For reverse lookups
-l Using AXFR to show list of all hosts in a domain
-m Memory debugging flag
-N Number of dots allowed, before root lookup
-r Stops recursive process
-R Set numbers of retries for UDP packets
-s Stop query if SERVFAIL received
-t Another query specification
-T TCP/IP mode enabled
-v Enable verbose output
-V Print version number and exit
-w Wait forever
-W Wait specific time in sec.
-4 IPv4 only
-6 IPv6 only

Host команда примери

Нека да ползваме Yahoo.com за примерите. Вие може да ползвате вашия домейн или домейн на ваш конкурент за пробите.

Виж IP адреса на избрания домейн

Отговорът ще е IPv4 и IPv6 адреси на набелязания домейн.

linux@linux:~$ host yahoo.com
yahoo.com has address 74.6.231.20
yahoo.com has address 74.6.143.25
yahoo.com has address 74.6.143.26
yahoo.com has address 98.137.11.164
yahoo.com has address 98.137.11.163
yahoo.com has address 74.6.231.21
yahoo.com has IPv6 address 2001:4998:124:1507::f000
yahoo.com has IPv6 address 2001:4998:124:1507::f001
yahoo.com has IPv6 address 2001:4998:44:3507::8001
yahoo.com has IPv6 address 2001:4998:44:3507::8000
yahoo.com has IPv6 address 2001:4998:24:120d::1:0
yahoo.com has IPv6 address 2001:4998:24:120d::1:1
yahoo.com mail is handled by 1 mta5.am0.yahoodns.net.
yahoo.com mail is handled by 1 mta6.am0.yahoodns.net.
yahoo.com mail is handled by 1 mta7.am0.yahoodns.net.

Виж SOA записа

Може да получите записа за главния нейм сървър (authoritative name server).

linux@linux:~$ host -C yahoo.com
Nameserver 68.180.131.16:
	yahoo.com has SOA record ns1.yahoo.com. hostmaster.yahoo-inc.com. 2020091412 3600 300 1814400 600
Nameserver 68.142.255.16:
	yahoo.com has SOA record ns1.yahoo.com. hostmaster.yahoo-inc.com. 2020091412 3600 300 1814400 600
Nameserver 98.138.11.157:
	yahoo.com has SOA record ns1.yahoo.com. hostmaster.yahoo-inc.com. 2020091412 3600 300 1814400 600
Nameserver 27.123.42.42:
	yahoo.com has SOA record ns1.yahoo.com. hostmaster.yahoo-inc.com. 2020091412 3600 300 1814400 600
Nameserver 202.165.97.53:
	yahoo.com has SOA record ns1.yahoo.com. hostmaster.yahoo-inc.com. 2020091412 3600 300 1814400 600

Покажи всички нейм сървъри на домейна

Показва списък с тях. „-t“ се ползва за специфичната заявка.

linux@linux:~$ host -t ns yahoo.com
yahoo.com name server ns2.yahoo.com.
yahoo.com name server ns3.yahoo.com.
yahoo.com name server ns5.yahoo.com.
yahoo.com name server ns1.yahoo.com.
yahoo.com name server ns4.yahoo.com.

Провери определен нейм сървър

Нека да вземем ns1, за това пишем:

linux@linux:~$ host yahoo.com ns1.yahoo.com
Using domain server:
Name: ns1.yahoo.com
Address: 68.180.131.16#53
Aliases: 

yahoo.com has address 98.137.11.163
yahoo.com has address 74.6.231.21
yahoo.com has address 74.6.231.20
yahoo.com has address 74.6.143.25
yahoo.com has address 98.137.11.164
yahoo.com has address 74.6.143.26
yahoo.com has IPv6 address 2001:4998:44:3507::8000
yahoo.com has IPv6 address 2001:4998:24:120d::1:1
yahoo.com has IPv6 address 2001:4998:124:1507::f000
yahoo.com has IPv6 address 2001:4998:24:120d::1:0
yahoo.com has IPv6 address 2001:4998:44:3507::8001
yahoo.com has IPv6 address 2001:4998:124:1507::f001
yahoo.com mail is handled by 1 mta6.am0.yahoodns.net.
yahoo.com mail is handled by 1 mta7.am0.yahoodns.net.
yahoo.com mail is handled by 1 mta5.am0.yahoodns.net.

Виж каноничния запис (CNAME)

linux@linux:~$ host -t cname mail.yahoo.com
mail.yahoo.com is an alias for edge.gycpi.b.yahoodns.net.

MX запис

За преглед на имейл сървъра (incoming mail server) ползвайте тази команда:

linux@linux:~$ host -n -t mx yahoo.com
yahoo.com mail is handled by 1 mta7.am0.yahoodns.net.
yahoo.com mail is handled by 1 mta6.am0.yahoodns.net.
yahoo.com mail is handled by 1 mta5.am0.yahoodns.net.

TXT записи

Може да видите всички TXT записи:

linux@linux:~$ host -t txt yahoo.com
yahoo.com descriptive text "v=spf1 redirect=_spf.mail.yahoo.com"
yahoo.com descriptive text "facebook-domain-verification=gysqrcd69g0ej34f4jfn0huivkym1p"
yahoo.com descriptive text "edb3bff2c0d64622a9b2250438277a59"

Задайте времето за изчакване на отговор

Напишете „-w“, за да чакате без лимит или „-W“ и след това секунди, за да изчака специфично време.

linux@linux:~$ host -T -W 10 yahoo.com
yahoo.com has address 74.6.231.21
yahoo.com has address 98.137.11.163
yahoo.com has address 98.137.11.164
yahoo.com has address 74.6.143.26
yahoo.com has address 74.6.143.25
yahoo.com has address 74.6.231.20
yahoo.com has IPv6 address 2001:4998:24:120d::1:1
yahoo.com has IPv6 address 2001:4998:24:120d::1:0
yahoo.com has IPv6 address 2001:4998:44:3507::8000
yahoo.com has IPv6 address 2001:4998:44:3507::8001
yahoo.com has IPv6 address 2001:4998:124:1507::f001
yahoo.com has IPv6 address 2001:4998:124:1507::f000
yahoo.com mail is handled by 1 mta7.am0.yahoodns.net.
yahoo.com mail is handled by 1 mta6.am0.yahoodns.net.
yahoo.com mail is handled by 1 mta5.am0.yahoodns.net.

Обратен преглед (Reverse lookup)

Почнете с IP адреса и стигнете до хоста.

linux@linux:~$ host 98.137.246.7
7.246.137.98.in-addr.arpa domain name pointer media-router-fp71.prod.media.vip.gq1.yahoo.com.

Всички DNS записи на този хост

Ще получите дълъг списък с DNS записи и ценна информация за тях.

linux@linux:~$ host -a yahoo.com
Trying "yahoo.com"
Trying "yahoo.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48527
;; flags: qr rd ra; QUERY: 1, ANSWER: 23, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;yahoo.com.			IN	ANY

;; ANSWER SECTION:
yahoo.com.		1214	IN	TXT	"facebook-domain-verification=gysqrcd69g0ej34f4jfn0huivkym1p"
yahoo.com.		1214	IN	TXT	"edb3bff2c0d64622a9b2250438277a59"
yahoo.com.		1214	IN	TXT	"v=spf1 redirect=_spf.mail.yahoo.com"
yahoo.com.		368	IN	AAAA	2001:4998:124:1507::f000
yahoo.com.		368	IN	AAAA	2001:4998:44:3507::8000
yahoo.com.		368	IN	AAAA	2001:4998:124:1507::f001
yahoo.com.		368	IN	AAAA	2001:4998:44:3507::8001
yahoo.com.		368	IN	AAAA	2001:4998:24:120d::1:1
yahoo.com.		368	IN	AAAA	2001:4998:24:120d::1:0
yahoo.com.		329	IN	MX	1 mta6.am0.yahoodns.net.
yahoo.com.		329	IN	MX	1 mta7.am0.yahoodns.net.
yahoo.com.		329	IN	MX	1 mta5.am0.yahoodns.net.
yahoo.com.		512	IN	A	98.137.11.164
yahoo.com.		512	IN	A	74.6.143.25
yahoo.com.		512	IN	A	74.6.231.20
yahoo.com.		512	IN	A	74.6.231.21
yahoo.com.		512	IN	A	74.6.143.26
yahoo.com.		512	IN	A	98.137.11.163
yahoo.com.		98741	IN	NS	ns3.yahoo.com.
yahoo.com.		98741	IN	NS	ns2.yahoo.com.
yahoo.com.		98741	IN	NS	ns1.yahoo.com.
yahoo.com.		98741	IN	NS	ns4.yahoo.com.
yahoo.com.		98741	IN	NS	ns5.yahoo.com.

Received 625 bytes from 127.0.0.53#53 in 5 ms

Заключение

Още един полезен софтуер за диагностика на мрежи, този път за потребителите на Linux. Идеален е за да наглеждате вашия домейн и производителността му.

Източник: https://www.geeksforgeeks.org/host-command-in-linux-with-examples/

Вашият коментар

Вашият имейл адрес няма да бъде публикуван.