Admin Power Level: Intermediate Chapter 11: Manage People, Computers, and Names
DNS records and zones
DNS turns names into addresses. In an Active Directory domain, DNS zones and records are the reason computers can find domain controllers and services by name.
Lesson 6 of 6 in Chapter 11: Manage People, Computers, and Names. Previous step in this path: Organisational units and groups. 3 learning objectives, 6 examples, and a knowledge check.
Start: what you will learn
DNS turns names into addresses. In an Active Directory domain, DNS zones and records are the reason computers can find domain controllers and services by name.
Learning objectives
- Explain a DNS zone and a resource record
- Create a DNS record and a zone
- Read and set a client DNS server address
Concept in simple words
What it is: DNS, which stands for Domain Name System, turns names into addresses, and in an Active Directory domain it is the reason computers can find domain controllers and services by name.
Why it works
Why it works this way: A DNS zone is the part of the DNS namespace that one server is responsible for, such as example.local. Inside a zone, resource records map names to values, for example an A record maps a host name to an IPv4 address, which is the numeric address used on the network, and an SRV record points to a service, such as a domain controller, so clients can discover it by asking DNS.
Think of it like this
Think of it like this: DNS is like a phone book for a town. A zone is one town book, and each record is one entry, a name next to a number, so when you look up a name, you get the number you need to reach that person, without memorising every number yourself.
How it works, step by step
How it works, step by step: First, on a DNS server, create records with Add-DnsServerResourceRecord, for example an A record with a host name and an IPv4 address, and create a primary zone with Add-DnsServerPrimaryZone when a whole new namespace is needed. These server commands need a proper server environment, the DNS tools, and the right permissions, and they are not meant for an ordinary client computer.
Next, on a client computer, check which DNS server it uses with Get-DnsClientServerAddress, and change it with Set-DnsClientServerAddress if needed. In a domain, clients should point to a domain DNS server, because that server knows the domain records, while a public DNS server alone does not.
Let us walk through an example: In Add-DnsServerResourceRecord -ZoneName "example.local" -A -Name "srv1" -IPv4Address "192.168.1.10", -ZoneName picks the zone, -A picks the record type, -Name gives the host name, and -IPv4Address gives the address to map it to. Look for a success message, then test the name from a client, because a record that only exists on the wrong server will not help anyone else resolve the name.
When to use it
When to use it, and when not to: Use server DNS commands on the DNS server itself, and use client DNS commands to check or fix where a client sends its name questions. Do not create a record on a client and expect the whole network to see it, and do not point a domain client at a public DNS server only, because then web names may work while domain names fail, which is a confusing mix that looks like the network is half broken.
Start from zero, with why names exist at all: Computers talk to each other with numeric addresses, but people remember names far better than numbers. DNS is the system that turns a name you can remember into an address a computer can use, and back again when needed. Without DNS, every user would need to memorise addresses, every server move would break every bookmark, and a domain, which is built entirely on names, could not work at all. DNS is not a convenience on top of a domain. It is the naming layer the domain stands on.
What happens behind a name lookup: When you type a name, your computer asks its configured DNS server, that server checks its zones, and if it holds the zone, it answers from its records. If it does not hold the zone, it asks onward, through forwarders or other servers, until an answer is found or the search fails. That chain is why two settings matter so much, which server the client asks, and which zones that server holds. A correct record on the wrong server helps nobody, and a correct server with the wrong client setting is never asked in the first place.
Forward lookup versus reverse lookup: A forward lookup zone answers the question, what address belongs to this name, and it holds records such as A records for IPv4 addresses. A reverse lookup zone answers the opposite question, what name belongs to this address, and it holds PTR records, which point an address back to a host name. Most daily work is forward lookup, but reverse lookup matters for logging, troubleshooting, and some services that check a name in both directions, so do not treat the reverse zone as decoration.
Record types, in plain words: An A record maps a host name to an IPv4 address. An AAAA record maps a host name to an IPv6 address. A CNAME record is an alias, so one name points to another name, which is useful when a service moves but its friendly name must stay the same. An MX record points mail for a domain to a mail server. A PTR record points an address back to a name. An SRV record points to a service, such as a domain controller or another named service, so clients can discover services by asking DNS. An NS record names the servers for a zone, and an SOA record holds the start of authority information for a zone. Learn A, CNAME, PTR, and SRV first, because those four explain most domain behaviour.
Zones, and where they live: A zone is the part of the DNS namespace that one server is responsible for, such as example.local. On a domain controller, a zone can be stored in Active Directory itself, which is called an AD integrated zone, and then it replicates with the directory to other controllers. On a standalone server, a zone can be stored in a file instead. The records look the same to a client either way, but the replication, the backup, and the update rules are different, so always know which kind of zone you are changing before you change it.
Let us walk through a primary zone, part by part: In Add-DnsServerPrimaryZone -Name "example.local" -ReplicationScope "Domain" -DynamicUpdate "Secure", -Name is the new zone, -ReplicationScope "Domain" says replicate this AD integrated zone to DNS servers in this domain, and -DynamicUpdate "Secure" says allow only secure dynamic updates, which means only authenticated domain computers can update their own records. Warning: this creates a zone on a DNS server, so run it only on a DNS server in your own lab domain, with permission. A zone created in the wrong place, or with the wrong replication scope, can confuse clients across the domain.
How long an answer lives: Every record has a TimeToLive, often shortened to TTL, which says how long another server or client may keep that answer in its cache before asking again. A long TTL means fewer queries, but a wrong address stays cached for longer after you fix it. A short TTL means fixes spread faster, but queries happen more often. When you change an address, remember the TTL, because a client that still holds the old cached answer is not broken, it is simply waiting for its cached answer to expire.
Forwarders, in plain words: A DNS server cannot hold every zone in the world, so for names outside its own zones, it forwards the question onward. A server level forwarder is used for all outside names, while a conditional forwarder is used for one specific namespace only, such as a partner domain. In a domain, clients should still ask a domain DNS server first, because only that server knows the domain SRV records. The domain server can then forward outside questions onward, so web names keep working without breaking domain names.
Let us walk through a client fix, part by part: First run Get-DnsClientServerAddress to see which DNS servers each adapter currently uses, and note the exact interface name. Then, only if the setting is wrong, run Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses "192.168.1.1", where -InterfaceAlias picks the adapter and -ServerAddresses sets the new DNS server list. Warning: this changes where that computer sends every name question, so use it only on a computer you are allowed to administer, and only with an address you have checked. After the change, run Get-DnsClientServerAddress again, and test a domain name, because a setting you never verify is only a guess.
Let us walk through a client test that names its server: Resolve-DnsName -Name "srv1.example.local" -Server "192.168.1.1" asks one specific DNS server, instead of whichever server the client normally uses. That distinction is the whole point of the test. If the named server answers correctly and the normal client setting fails, the record is fine and the client setting is wrong. If the named server also fails, the record or the zone is the problem. Testing without naming a server cannot tell those two cases apart, so name the server whenever you are troubleshooting.
Worked examples
Read each example in order. Each one explains its parts, then shows what to look for in the output.
Syntax
Add-DnsServerResourceRecord -ZoneName <Zone> -A -Name <Host> -IPv4Address <Address>Example 1
Creates an A record so srv1.example.local resolves to that address. Runs on a DNS server.
Add-DnsServerResourceRecord -ZoneName "example.local" -A -Name "srv1" -IPv4Address "192.168.1.10"Illustrative output: Record srv1 created in example.local.
Example 2
Shows which DNS servers this adapter currently uses.
Get-DnsClientServerAddress -InterfaceAlias "Ethernet" | Select-Object ServerAddressesIllustrative output: ServerAddresses --------------- 192.168.1.1
Example 3
Get-DnsServerResourceRecord reads records from a DNS server, and -ZoneName "example.local" picks which zone to read. -RRType A limits the result to A records, which are host name to IPv4 address mappings, so you do not wade through every record type at once. Select-Object HostName, RecordData then shows each host name next to its address data, which is the quickest way to check what a zone actually holds. This is a server command, so it needs a DNS server, the DNS tools, and the right permissions.
Get-DnsServerResourceRecord -ZoneName "example.local" -RRType A | Select-Object HostName, RecordDataIllustrative output: HostName RecordData -------- ---------- srv1 192.168.1.10
Example 4
Warning: this creates an AD integrated primary zone on a DNS server, so run it only on a DNS server in your own lab domain, with permission. -ReplicationScope Domain limits replication to DNS servers in this domain. -DynamicUpdate Secure allows only secure dynamic updates.
Add-DnsServerPrimaryZone -Name "example.local" -ReplicationScope "Domain" -DynamicUpdate "Secure"Illustrative output: Zone example.local created.
Example 5
A read only test against one named DNS server. If this server answers and the normal client setting fails, the client setting is wrong. If this server also fails, the record or the zone is the problem.
Resolve-DnsName -Name "srv1.example.local" -Server "192.168.1.1"Illustrative output: Name Type TTL Section IPAddress ---- ---- --- ------- --------- srv1.example.local A 3600 Answer 192.168.1.10
Example 6
Warning: this changes where this computer sends every name question, so use it only on a computer you are allowed to administer, with a DNS address you have checked. Confirm afterwards with Get-DnsClientServerAddress, and test a domain name.
Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses "192.168.1.1"Illustrative output: DNS server address set to 192.168.1.1.
Nothing on this page executes PowerShell code. The outputs above are illustrative only.
Common mistakes and troubleshooting
Read these before you try the examples, so you can spot the same problems in your own work.
- Creating a DNS record on a client instead of on the DNS server, then wondering why nobody else resolves it.
- Pointing a domain client at a public DNS server only, so domain names fail while web names work.
- Creating a DNS record with a typo in the address, then testing from the same server and thinking it works, without testing from a client, where the wrong address sends traffic to the wrong place.
- Creating a record in the wrong zone, so the full name clients ask for is not the name you created, and the lookup fails even though a similar record exists.
- Creating a second A record for the same name with a different address, without realising it, so clients get sent to different addresses on different lookups, and the fault looks random.
- Changing an address and declaring the fix a failure at once, when clients still hold the old answer in cache until its TimeToLive expires.
- Changing a client DNS setting without noting the interface name first, then applying the change to the wrong adapter and wondering why nothing changed.
Knowledge check
Knowledge check
What does an A record map?
Pick one answer. Feedback appears right away, and you can try again.
Remember this and next step
Remember this: Zones hold records, records turn names into addresses and services, domain clients must ask a domain DNS server, and server DNS work stays on the server, with the right tools and permissions.
Next step: Show, disable, and enable scheduled tasks