Manage DNS resource records
Create, modify, and delete DNS resource records using the DNS server role in Windows Server. You can add resource records using DNS manager, using Windows PowerShell, or automatically when Windows-based, Dynamic Host Configuration Protocol (DHCP) enabled clients join a network using dynamic update.
Resource records contain the information that a zone maintains about the resources (such as hosts). Resource record information includes record type, owner name, host address and other information.
Prerequisites
Before you can manage DNS resource records in Windows Server, you need to complete the following prerequisites:
- A Windows Server with the DNS Server role installed and configured. See Quickstart: Installing and configure DNS Server for more information on how to get stared.
- Determine the type of record you want to create, see DNS resource records.
- An account that is a member of the Administrators group, or equivalent.
- You need the fully qualified domain name (FQDN) and the IP address of the resource record you want to create.
Create resource records
You can add resource records to an existing zone using the DnsServer PowerShell module. Some common resource record types have other PowerShell commands where you don't need to specify the resource record type. You can also add the following types of resource records using the DNS Manager console.
The following sections contain steps for creating the following types of resource records:
- Host (A or AAAA)
- Alias (CNAME)
- Mail Exchanger (MX)
- Pointer (PTR)
- Service Locator (SRV)
- Text (TXT)
Create a host record
To create an IPv4 host (A) record, select the relevant method and follow the steps.
Here's how to create an IPv4 host (A) using the Add-DnsServerResourceRecord PowerShell command.
To create a host resource record for Host34
mapped to the IP address 10.17.1.34
for the zone
contoso.com
, run the following command.
Add-DnsServerResourceRecordA -Name "Host34" -ZoneName "Contoso.com" -IPv4Address "10.17.1.34" -TimeToLive 01:00:00
You can also add an IPv4 host (A) record using the Add-DnsServerResourceRecord.
AAAA resource record
To create an IPv6 host (AAAA) record, select the relevant method and follow the steps.
Here's how to create an IPv6 host (AAAA) using the Add-DnsServerResourceRecordAAAA PowerShell command.
To add the AAAA resource record Host36
to map to IPv6 address 3ffe::1
, use the command:
Add-DnsServerResourceRecordAAAA -Name "Host36" -ZoneName "contoso.com" -IPv6Address "3ffe::1" -TimeToLive 01:00:00
You can also add an IPv6 host (AAAA) record using the Add-DnsServerResourceRecord.
CNAME records
To create an alias (CNAME) record, select the relevant method and follow the steps.
Here's how to create a CNAME resource record using the Add-DnsServerResourceRecordCName PowerShell command.
To have the CNAME labhost34
be created in the contoso.com
zone and point to the existing DNS
record Host34.lab.contoso.com
, use the following PowerShell command:
Add-DnsServerResourceRecordCName -Name "labhost34" -HostNameAlias "Host34.lab.contoso.com" -ZoneName "contoso.com" -TimeToLive 01:00:00
MX records
To create an MX record, select the relevant method and follow the steps.
Here's how to create an MX resource record using the Add-DnsServerResourceRecordMX PowerShell command.
To add an MX record for the host mail.contoso.com
with a preference set to 10
for the
contoso.com
zone, use the following PowerShell command:
Add-DnsServerResourceRecordMX -Preference 10 -Name "." -TimeToLive 01:00:00 -MailExchange "mail.contoso.com" -ZoneName "contoso.com"
PTR records
To create a PTR record, select the relevant method and follow the steps.
Here's how to create a PTR resource record using the Add-DnsServerResourceRecordPtr PowerShell command.
To add a pointer record named host77.contoso.com
for the IP address 192.168.0.77
in the reverse
lookup zone 0.168.192.in-addr.arpa
, use the following PowerShell command:
Add-DnsServerResourceRecord -Name "77" -Ptr -ZoneName "0.168.192.in-addr.arpa" -AllowUpdateAny -PtrDomainName "host77.contoso.com"
SRV records
To create an SRV record, select the relevant method and follow the steps.
Here's how to create an SRV resource record using the Add-DnsServerResourceRecord PowerShell command.
To add a service locator (SRV) resource record for the _sip
service on port 5060
with a weight
and priority of 0
for the contoso.com
domain pointing to sipserver1.contoso.com
, use the
following PowerShell command:
Add-DnsServerResourceRecord -Srv -Name "sip" -ZoneName "contoso.com" -DomainName "sipserver1.contoso.com" -Priority 0 -Weight 0 -Port 5060
TXT records
To create a TXT record, select the relevant method and follow the steps.
Here's how to create a TXT resource record using the Add-DnsServerResourceRecord PowerShell command.
To create a TXT record named example with the text value Example DNS record text
in the
contoso.com
zone, use the following PowerShell command:
$recordtext = “Example DNS record text”
Add-DnsServerResourceRecord -DescriptiveText $recordtext -Name example -zonename contoso.com
Update resource records
To update a resource record, select the relevant method and follow the steps.
Here's how to modify the time to live (TTL) for a DNS resource record using the Get-DnsServerResourceRecord and Set-DnsServerResourceRecord PowerShell commands.
The following example updates the resource record host01.contoso.com
so that the TTL is now 2
hours. In this example, you use the OldInputObject parameter to specify a resource record object
that you want to change and the NewInputObject parameter to specify the updated values.
To update the resource record host01.contoso.com
so that the TTL is now 2 hours, run the following
PowerShell commands:
$OldObj = Get-DnsServerResourceRecord -Name "host01" -ZoneName "contoso.com" -RRType "A"
$NewObj = [ciminstance]::new($OldObj)
$NewObj.TimeToLive = [System.TimeSpan]::FromHours(2)
Set-DnsServerResourceRecord -NewInputObject $NewObj -OldInputObject $OldObj -ZoneName "contoso.com" -PassThru
The Set-DnsServerResourceRecord PowerShell command can't change the Name or Type of a DNS server resource record object. If you want to perform those actions, remove the existing resource record and create a new one.
Remove resource records
To remove a resource record, select the relevant method and follow the steps.
Here's how to remove a DNS resource record using the Remove-DnsServerResourceRecord PowerShell command.
To remove the DNS record example.contoso.com
, run the following command:
Remove-DnsServerResourceRecord -name "Example" -Zonename "contoso.com" -RRType A