ip name-server, ip domain-name and static ip host entries, and why a mistyped command makes the router pause.
Beginner · 7 min read
Technical definition
DNS on Cisco devices means the router or switch resolving names to IP addresses itself, so you can type ping www.example.com or telnet to a hostname, and so features such as SSH key generation have the domain name they need.
Three things to set
Example commands and output on this page were written from Cisco IOS documentation and generally described behaviour. They were not captured from a live device, so prompts and details can differ on your platform and version.
DNS commands on IOS
On small screens, swipe sideways or focus the diagram and use the arrow keys.
The address 192.0.2.53 is from the documentation range; use your own DNS server.
configure terminal
ip domain-name example.com
ip name-server 192.0.2.53
ip host R2 10.0.0.2
end
The router now resolves other names through 192.0.2.53, and R2 resolves to 10.0.0.2 even without a server.
Testing it
Example output · based on Cisco documentation; exact format varies by platform and software version
R1#ping www.example.com
Translating "www.example.com"...domain server (192.0.2.53) [OK]
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 203.0.113.80, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5)
Example output. The first line shows the router asking the name server and getting an answer. The target address is from the documentation range.
The mistyped-command pause
Example output · based on Cisco documentation; exact format varies by platform and software version
R1#shwo ip route
Translating "shwo"...domain server (255.255.255.255)
% Unknown command or computer name, or unable to find computer address
Example output. With no name server configured, IOS broadcasts the lookup and waits. This is why labs and production devices often have no ip domain-lookup.
Keep lookup on only if the device uses names, for example for NTP or syslog by hostname.
Test yourself
Predict · scenario 1
A router waits many seconds after you type shwo. What turns this off?
Predict · scenario 2
Which command is needed before crypto key generate rsa will work for SSH?
Predict · scenario 3
Which command defines a static name to address mapping on the router?
FAQ
Why does my router pause when I mistype a command?
IOS treats an unknown word as a hostname and tries to resolve it, sending a DNS request to the broadcast address if no server is set. Turn that off with no ip domain-lookup, or press Ctrl+Shift+6 to abort.
Do I need ip domain-name?
For SSH, yes: crypto key generate rsa needs a hostname and a domain name to build the key name. It is also appended to short names you type.
Can a Cisco router be a DNS server?
It can answer simple queries with ip dns server for names defined with ip host, which is mainly for labs. It is not a replacement for a real DNS server.