Skip to content

k.net.DNS

DNS lookups, reverse resolution, and Whois

Overview

k.net.DNS provides host name resolution and email/domain name related record query. The attribute name is DNS (case sensitive).

getIPs()

Resolve the hostname to get a list of IPs.

ts
k.api.get("resolve", () => {
    const ips = k.net.DNS.getIPs("kooboo.com")
    return {
        count: ips ? ips.length : 0,
        first: ips && ips[0] ? ips[0].address : null
    }
})
OverloadDescription
getIPs(host)Use system DNS
getIPs(nsServer, host)Specify NS server to query A records
ParameterTypeRequiredDescription
hoststringYesHostname or domain to resolve.
nsServerstringNoDNS server to query.

Returns: KIPAddress[] or null

KIPAddress

Field/MethodDescription
addressIP string
isIP4 / isIP6address family
toIP4() / toIP6()mapped string

getMXs()

Query MX records.

OverloadDescription
getMXs(host)Default parsing
getMXs(nsServer, host)Specify NS
ParameterTypeRequiredDescription
hoststringYesDomain to query MX records for.
nsServerstringNoDNS server to query.

Returns: string[] or null

ts
const records = k.net.DNS.getMXs("kooboo.com")

getNsServers()

Get the NS server list of the domain name.

ParameterTypeRequiredDescription
hoststringYesDomain to query NS records for.

Returns: string[] | null. NS server list.

ts
const ns = k.net.DNS.getNsServers("kooboo.com")

getReverseDNS()

Do reverse DNS on the IP.

ParameterTypeRequiredDescription
ipstringYesIP address to reverse resolve.

Returns: string | null. Resolved hostname.

ts
const host = k.net.DNS.getReverseDNS("8.8.8.8")

whoisInfo()

Returns the original Whois record text for a domain name.

ParameterTypeRequiredDescription
domainstringYesDomain to query Whois for.

Returns: string | null. Raw Whois text.

ts
const raw = k.net.DNS.whoisInfo("kooboo.com")
  • k.net.IP — IP geography (complementary to DNS resolution)