Checking DNS
Tcl can be used to query Domain Name Servers using the dns
package. This package allows us to query for various domain-related information. The package is an implementation of the DNS protocol client and it uses the DNS servers configured on the system by default. Although, it can also be configured to use different name servers.
The main command for querying DNS is dns::resolve
, which returns a token that can then be used to get results. This command should be invoked with the query as the first argument and all options appended after it. The query can have multiple formats—the first one being the hostname. It can also be specified as dns:<hostname>
or dns://<servername>/<hostname>
where servername
is the name of DNS server sent to the query.
The result from a query can be multiple servers. For example, in order to check the IP addresses of www.google.com, we can do the following:
package require dns set token [dns::resolve "www.google.com"]
As DNS queries...