大网数据广告活动
网络与域名解析

Manage DNS resource records using DNS server on Windows Server

· 52CE 我爱测

Learn more about how to manage DNS resource records on Windows Server.

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.

PowerShell

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.

GUI

Here's how to create an IPv4 host (A) record for Host32 mapped to the IP address 10.17.1.32 for the zone contoso.com using DNS Manager.

  1. From the Windows desktop, open the Start menu, select Windows Administrative Tools > DNS.

  2. In the console tree, connect to the DNS server you wish to manage, expand the DNS server, expand your Forward Lookup Zone, right-click, then select New Host (A or AAAA).

  3. On the New Host screen, specify the name and IP address of the host record. For example, Host32 and 10.17.1.32.

  4. Select Add Host to create the record.


AAAA resource record

To create an IPv6 host (AAAA) record, select the relevant method and follow the steps.

PowerShell

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.

GUI

Here's how to create an IPv6 host (AAAA) record for Host34 mapped to the IPv6 address 3ffe::1 for the zone contoso.com using DNS Manager.

  1. From the Windows desktop, open the Start menu, select Windows Administrative Tools > DNS.

  2. In the console tree, connect to the DNS server you wish to manage, expand the DNS server, expand your Forward Lookup Zone, right-click, then select New Host (A or AAAA).

  3. On the New Host screen, specify the name and IP address of the host record. For example, Host34 and 3ffe::1.

  4. Select Add Host to create the record.


CNAME records

To create an alias (CNAME) record, select the relevant method and follow the steps.

PowerShell

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
GUI

Here's how to create a CNAME resource record for labhost34 in the contoso.com zone, pointing to the existing DNS record Host34.lab.contoso.com using DNS Manager.

  1. From the Windows desktop, open the Start menu, select Windows Administrative Tools > DNS.

  2. In the console tree, connect to the DNS server you wish to manage, expand the DNS server, expand your Forward Lookup Zone, right-click, then select New Alias (CNAME).

  3. On the New Resource Record screen, specify the alias name and FQDN for the target host. For example, labhost34 and Host34.lab.contoso.com.

  4. Select OK to create the resource record.


MX records

To create an MX record, select the relevant method and follow the steps.

PowerShell

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"
GUI

Here's how to create an MX resource record for the host mail2.contoso.com with a preference set to 20 for the contoso.com zone using DNS Manager.

  1. From the Windows desktop, open the Start menu, select Windows Administrative Tools > DNS.

  2. In the console tree, connect to the DNS server you wish to manage, expand the DNS server, expand your Forward Lookup Zone, right-click, then select New Mail Exchanger (MX).

  3. On the New Resource Record screen, specify the host or child domain, if applicable, the FQDN of the mail server, and the mail server priority. For example, leave the host of child domain blank, enter mail2.contoso.com for the mail server and 20 for the mail server priority.

  4. Select OK to create the resource record.


PTR records

To create a PTR record, select the relevant method and follow the steps.

PowerShell

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"
GUI

Here's how to create a PTR record named host77.contoso.com for the IP address 192.168.0.77 in the reverse lookup zone 0.168.192.in-addr.arpa using DNS Manager.

  1. From the Windows desktop, open the Start menu, select Windows Administrative Tools > DNS.

  2. In the console tree, connect to the DNS server you wish to manage, expand the DNS server, expand your Reverse Lookup Zone, right-click, then select New Pointer (PTR).

  3. On the New Resource Record screen, specify the host IP address, and host name. For example, enter 192.168.0.77 for the host IP address and host77.contoso.com for the host name.

  4. Select OK to create the resource record.


SRV records

To create an SRV record, select the relevant method and follow the steps.

PowerShell

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
GUI

Here's how to create an 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 using DNS Manager.

  1. From the Windows desktop, open the Start menu, select Windows Administrative Tools > DNS.

  2. In the console tree, connect to the DNS server you wish to manage, expand the DNS server, expand your Forward Lookup Zone, right-click, then select Other New Records.

  3. Select Service Locator (SRV) from the list, then select Create Record.

  4. On the New Resource Record screen, specify the service, protocol, priority, weight, port number, and host offering this service. For example, enter _sip for service, 5060 for the port, a weight and priority of 0, and sipserver1.contoso.com as the host.

  5. Select OK to create the resource record.


TXT records

To create a TXT record, select the relevant method and follow the steps.

PowerShell

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
GUI

Here's how to create a TXT record named example with the text value Example DNS record text in the contoso.com zone using DNS Manager.

  1. From the Windows desktop, open the Start menu, select Windows Administrative Tools > DNS.

  2. In the console tree, connect to the DNS server you wish to manage, expand the DNS server, expand your Forward Lookup Zone, right-click, then select Other New Records.

  3. Select Text (TXT) from the list, then select Create Record.

  4. On the New Resource Record screen, specify the record name and the text value. For example, leave the record name as blank to use the contoso.com parent domain, then enter the text Example DNS record text.

  5. Select OK to create the resource record.


Update resource records

To update a resource record, select the relevant method and follow the steps.

PowerShell

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.

GUI

Here's how to modify the time to live (TTL) for a DNS resource record using DNS Manager.

  1. From the Windows desktop, open the Start menu, select Windows Administrative Tools > DNS.

  2. Expand View menu from the menu bar, then select Advanced.

  3. In the console tree, connect to the DNS server you wish to manage, expand the DNS server, expand your Forward Lookup Zone, find and right-click the record, then select Properties.

  4. On the Properties screen, specify the TTL value. For example, enter a TTL of 2 hours in the format 0:2:0:0.

  5. Select OK to update the resource record.


Remove resource records

To remove a resource record, select the relevant method and follow the steps.

PowerShell

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
GUI

Here's how to remove a record named example in the contoso.com zone using DNS Manager.

  1. From the Windows desktop, open the Start menu, select Windows Administrative Tools > DNS.

  2. Expand View menu from the menu bar, then select Advanced.

  3. In the console tree, connect to the DNS server you wish to manage, expand the DNS server, expand your Forward Lookup Zone, find and right-click the record, then select Delete.


Source: Microsoft Learn / Windows Server documentation by Microsoft and contributors (upstream author metadata: robinharwood). Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Server documentation
适用范围
Windows Server · Source date 06/14/2023
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。