Courseiva
DHCPDHCP Pool Config

dns-server [ip]

Specifies the DNS server IP address(es) that will be assigned to DHCP clients on a specific DHCP pool.

Definition: dns-server [ip] is a Cisco IOS dhcp pool config command. Specifies the DNS server IP address(es) that will be assigned to DHCP clients on a specific DHCP pool.

Overview

The `dns-server` command, used in DHCP pool configuration mode on Cisco IOS devices, specifies the DNS server IP address(es) that will be assigned to DHCP clients. This command is critical for enabling clients to resolve domain names to IP addresses, which is essential for internet and network resource access. Without DNS server assignment, clients would need to use IP addresses directly or rely on manual DNS configuration, leading to operational inefficiency.

The command supports up to eight DNS server addresses, which are provided to clients in the order listed. This command is typically used when configuring a DHCP server on a router or switch to serve a subnet, ensuring that clients receive necessary network parameters automatically. Alternatives include using the `ip dhcp-server` command for external DHCP servers or manual client configuration, but the `dns-server` command is the standard method for integrated DHCP services.

In the broader workflow, after creating a DHCP pool with `ip dhcp pool`, you define the network, default gateway, and DNS servers. The command immediately affects the running configuration and takes effect when clients renew their leases. It requires privileged EXEC mode (enable) and is part of the DHCP pool configuration submode.

The command is stored in the running configuration and can be saved to startup configuration. Understanding this command is fundamental for CCNA and CCNP candidates as DHCP is a core network service.

Syntax·DHCP Pool Config
dns-server [ip]

When to Use This Command

  • Assigning a corporate DNS server to hosts in a VLAN so they can resolve internal domain names.
  • Providing a public DNS server like 8.8.8.8 to clients in a guest network.
  • Configuring multiple DNS servers for redundancy in a production DHCP pool.
  • Updating DNS server addresses in an existing pool without deleting and recreating the pool.

Parameters

ParameterSyntaxDescription
ipA.B.C.DSpecifies the IP address of the DNS server. Up to eight DNS server addresses can be entered in a single command or multiple commands. The addresses are assigned to clients in the order they are configured. Common mistakes include using an invalid IP address or forgetting to configure at least one DNS server, which may cause clients to fail DNS resolution.

Command Examples

Assign a single DNS server to a DHCP pool

dns-server 192.168.1.1

No output is generated; the command silently configures the DNS server address. Use 'do show ip dhcp pool' to verify.

Assign multiple DNS servers to a DHCP pool

dns-server 192.168.1.1 8.8.8.8

Multiple DNS servers can be specified in order of preference. Clients will receive both addresses.

Understanding the Output

This command does not produce output upon execution. To verify the configured DNS servers, use 'show ip dhcp pool [pool-name]'. The output will list the DNS server(s) under 'DNS server' field.

For example: 'DNS server : 192.168.1.1, 8.8.8.8'. If no DNS server is configured, the field will be absent or show 'None'. Ensure the IP addresses are reachable and correct for client resolution.

Configuration Scenarios

Configure DNS server for a LAN DHCP pool

A small office network uses a Cisco router as the DHCP server for the 192.168.1.0/24 LAN. The goal is to assign Google's public DNS server (8.8.8.8) to clients so they can resolve internet domain names.

Topology

PC1---(Gi0/0)Router(Gi0/0)---Internet LAN: 192.168.1.0/24

Steps

  1. 1.Step 1: Enter global configuration mode: Router> enable; Router# configure terminal
  2. 2.Step 2: Create a DHCP pool named LAN-POOL: Router(config)# ip dhcp pool LAN-POOL
  3. 3.Step 3: Define the network: Router(dhcp-config)# network 192.168.1.0 255.255.255.0
  4. 4.Step 4: Set the default gateway: Router(dhcp-config)# default-router 192.168.1.1
  5. 5.Step 5: Specify the DNS server: Router(dhcp-config)# dns-server 8.8.8.8
  6. 6.Step 6: Exit DHCP config: Router(dhcp-config)# exit
  7. 7.Step 7: Verify: Router(config)# do show ip dhcp pool
Configuration
!
ip dhcp pool LAN-POOL
 network 192.168.1.0 255.255.255.0
 default-router 192.168.1.1
 dns-server 8.8.8.8
!

Verify: Use `show ip dhcp pool` to see the pool configuration. Use `show ip dhcp binding` to see active leases. On a client, run `ipconfig /all` (Windows) or `ifconfig` (Linux) to confirm DNS server is 8.8.8.8.

Watch out: If the DNS server IP is not reachable from the router, clients will still receive it but DNS resolution will fail. Ensure the router has a route to the DNS server or use a local DNS server.

Configure multiple DNS servers for redundancy

A medium-sized enterprise requires redundant DNS servers for high availability. The DHCP pool for the 10.10.10.0/24 subnet should assign both a primary (10.10.10.2) and secondary (10.10.10.3) DNS server.

Topology

Server1(10.10.10.2)---Switch---Router---Clients Server2(10.10.10.3)---Switch---Router LAN: 10.10.10.0/24

Steps

  1. 1.Step 1: Enter global configuration mode: Router> enable; Router# configure terminal
  2. 2.Step 2: Create DHCP pool: Router(config)# ip dhcp pool CORP-LAN
  3. 3.Step 3: Define network: Router(dhcp-config)# network 10.10.10.0 255.255.255.0
  4. 4.Step 4: Set default gateway: Router(dhcp-config)# default-router 10.10.10.1
  5. 5.Step 5: Specify both DNS servers: Router(dhcp-config)# dns-server 10.10.10.2 10.10.10.3
  6. 6.Step 6: Exit: Router(dhcp-config)# exit
  7. 7.Step 7: Verify: Router(config)# do show run | section ip dhcp pool
Configuration
!
ip dhcp pool CORP-LAN
 network 10.10.10.0 255.255.255.0
 default-router 10.10.10.1
 dns-server 10.10.10.2 10.10.10.3
!

Verify: Use `show ip dhcp pool` to confirm both DNS servers are listed. On a client, check DNS server list; it should show both addresses. Test DNS resolution with `nslookup`.

Watch out: The order of DNS servers matters; clients will try the first one first. If the first server is slow or unreachable, clients may experience delays. Ensure both servers are operational and reachable.

Troubleshooting with This Command

When troubleshooting DNS server assignment via DHCP, the `dns-server` command is often checked after clients report inability to resolve domain names. Healthy output from `show ip dhcp pool` should list the configured DNS servers under the pool. If no DNS servers appear, the command may be missing or misconfigured.

Use `show running-config | section ip dhcp pool` to verify the configuration. Common symptoms include clients receiving an IP address but not being able to browse the internet by name. In such cases, check the DHCP binding with `show ip dhcp binding` to see if the client has a lease.

If the lease exists but DNS is missing, the pool configuration is likely incomplete. Another useful command is `debug ip dhcp server events` to see the DHCP packets exchanged; look for option 6 (DNS server) in the DHCP offer and acknowledge packets. If the DNS server IP is incorrect or unreachable, clients may still receive it but DNS queries will time out.

Verify connectivity from the router to the DNS server using `ping`. Also ensure that the DNS server is configured to allow queries from the client subnet. In some cases, the router itself may be acting as a DNS proxy; if so, the `ip dns server` command must be enabled.

For IOS-XE, the troubleshooting steps are similar, but the output format may differ slightly. Always correlate the DHCP pool configuration with the actual lease information to isolate issues.

CCNA Exam Tips

1.

CCNA exam may ask which command assigns a DNS server to a DHCP pool; answer is 'dns-server' under DHCP pool configuration mode.

2.

Remember that multiple DNS servers can be listed in one command, separated by spaces.

3.

The command is configured per DHCP pool, not globally; each pool can have different DNS servers.

4.

Be aware that the DNS server IP must be reachable from clients; exam might test troubleshooting scenarios.

Common Mistakes

Mistake: Forgetting to enter DHCP pool configuration mode before using 'dns-server'. Consequence: Command rejected or applied to wrong pool.

Mistake: Using 'ip dns-server' instead of 'dns-server'. Consequence: Command not recognized.

Mistake: Not verifying with 'show ip dhcp pool' after configuration. Consequence: Undetected misconfiguration.

dns-server [ip] vs ip dhcp pool [name]

Both 'ip dhcp pool [name]' and 'dns-server [ip]' are essential for configuring Cisco IOS DHCP server functionality, but they operate at different levels. 'ip dhcp pool' creates the DHCP pool and enters its configuration submode, while 'dns-server' is a subcommand used within that submode to assign DNS server addresses to clients. They are commonly confused because 'dns-server' is often the first option configured after creating a pool, leading to the misconception that it is a standalone command.

Aspectdns-server [ip]ip dhcp pool [name]
ScopeApplies only to one DHCP pool after creation.Creates and enters the configuration context for a DHCP pool.
Configuration modeDHCP Pool Configuration mode (submode of DHCP pool).Global Configuration mode.
PurposeSpecifies DNS server IPs for clients.Defines the pool name, subnet, gateway, and other options.
PersistencePersists only when pool exists; part of pool config.Persists as top-level DHCP pool definition.
PrecedenceSubordinate to pool; must be inside a pool.Parent command; other pool options follow.
Typical useUsed after pool creation to set DNS servers.Used first to create and name the DHCP pool.

Use dns-server [ip] when you need to assign specific DNS server addresses to DHCP clients within an already-created DHCP pool.

Use ip dhcp pool [name] when you need to create a new DHCP pool and enter its configuration mode to define address range, gateway, DNS, and other DHCP parameters.

Platform Notes

On IOS-XE, the `dns-server` command syntax is identical to classic IOS. However, in NX-OS (Cisco Nexus switches), the equivalent command is `ip dhcp-server` with a different configuration model. NX-OS uses `ip dhcp relay` for DHCP relay and does not have a built-in DHCP server in the same way; instead, it relies on an external server or the `feature dhcp` with `ip dhcp pool` but the syntax for DNS is `dns-server` within the pool configuration.

On ASA firewalls, DHCP server configuration is done via `dhcpd dns` command in interface configuration mode, e.g., `dhcpd dns 8.8.8.8 interface inside`. IOS-XR does not support a native DHCP server; it uses DHCP relay or external servers. In older IOS versions (12.x), the command is the same, but the maximum number of DNS servers may be limited to two.

In 15.x and later, up to eight are supported. The command is available in all IOS versions that support DHCP server functionality. Always verify the specific platform documentation for any nuances.

Related Commands

Practice for the CCNA 200-301

Test your knowledge with practice questions covering all CCNA 200-301 exam domains.

Practice CCNA 200-301 Questions