turbot/net_insights
Loading controls...

Control: Primary name server should be listed at parent

Description

The primary name server is the name server declared in your SOA file and generally reads your records from zone files. It is responsible for distributing the data to secondary name servers. Unmatched NS records can cause delays when resolving domain records, as it tries to contact a name server that is either non-existent or non-authoritative.

Usage

Run the control in your terminal:

powerpipe control run net_insights.control.dns_soa_primary_ns_listed_at_parent

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe control run net_insights.control.dns_soa_primary_ns_listed_at_parent --share

Steampipe Tables

Params

ArgsNameDefaultDescriptionVariable
$1domain_names
["github.com","microsoft.com"]
DNS domain names.

SQL

with primary_ns_from_soa_record as (
select
domain as domain_add,
target as primary_ns
from
net_dns_record
where
domain in (
select
jsonb_array_elements_text(to_jsonb($1 :: text [ ]))
)
and type = 'SOA'
),
all_ns as (
select
domain,
target
from
net_dns_record
where
domain in (
select
jsonb_array_elements_text(to_jsonb($1 :: text [ ]))
)
and type = 'NS'
)
select
ans.domain as resource,
case
when count(*) = 0 then 'alarm'
else 'ok'
end as status,
case
when count(*) = 0 then ans.domain || ' primary name server not listed at parent.'
else ans.domain || ' primary name server listed at parent.'
end as reason
from
all_ns as ans
left join primary_ns_from_soa_record as pns on pns.domain_add = ans.domain
and ans.target = pns.primary_ns
group by
ans.domain;