Adding A Record

This article contains an example on how to add an A Record in DNS Server using Powershell.

Pre-Requisite:

  • Make sure you are using an account that has permission to add DNS entries.
  • If in case the CommServe host is not on the same domain as the DNS server, enable dynamic updates on the DNS controller using the following command:
dnscmd.exe /Config myrootdns.com /AllowUpdate 1

Adding DNS Entry in a Windows Server

Powershell command:


powershell.exe "Add-DnsServerResourceRecordA -Name " HOSTNAME " -ComputerName " SRVNAME " -ZoneName " ZONE " -AllowUpdateAny -IPv4Address " A_RECORD_IP " -TimeToLive " 00:00:10

Where:

    • HOSTNAME = hostname of the A record that will be added
    • SRVNAME = hostname or IP Address of the DNS Server to where you need to add the record. It can be “localhost” if adding locally.
    • ZONE = Name of the DNS Zone to where you intend to add the A Record.
    • A_RECORD_IP = IP Address to where the A record will be pointed to.

After executing the command, the DNS zone puchufy.com in this example shows that the A record has been added.

Adding A record to a remote DNS Server

Before being able to add an A record to a remote DNS server, connect to remote Powershell session of the DNS Server.

To connect to remote PSSession, enter the following command, and provide the credentials for authorized user to configure DNS records:

Enter-PSSession -ComputerName DNS_SERVER_IP_ADDRESS -Credential $cred

Once connected, execute this command:

powershell.exe "Add-DnsServerResourceRecordA -Name " A_RECORD_NAME " -ComputerName " DNS_SERVER_HOSTNAME " -ZoneName " ZONE_NAME " -AllowUpdateAny -IPv4Address " A_RECORD_IP " -TimeToLive " 00:00:10

 

Where:

  • A_RECORD_NAME = Name of the A Record to be added
  • DNS_SERVER_HOSTNAME = Hostname or IP address of the DNS server where A record will be added.
  • ZONE_NAME = Zone to where the A record will be added.
  • A_RECORD_IP = IP address of the A record.

See sample execution:

Notice that the A record has been added: