ip name-server configures the DNS server or servers that a Cisco IOS device queries to resolve domain names. The router must also have DNS lookup enabled, which is the default. section 3.2.1
Key configuration facts:
- Specify up to six DNS servers, either in one command or through separate commands. section 3.2.1
- If the first server fails to resolve a name, IOS queries the other configured servers. section 3.2.1
- Use ip dns server separately when the router must answer DNS queries from client devices; ip name-server supplies its upstream resolvers. section 3.2.2
Configure and verify resolution
R1(config)# ip name-server 8.8.8.8 R1(config)# do ping google.com Translating "google.com"... domain server (8.8.8.8) [OK] !!!!! The command identifies 8.8.8.8 as R1’s DNS server, allowing the hostname to resolve before the ICMP test runs. section 3.2.1
R1# ping google.com Translating "google.com"...domain server (255.255.255.255) % Unrecognized host or address, or protocol not running. #1 R1# configure terminal R1(config)# ip name-server 8.8.8.8 #2 R1(config)# do ping google.com Translating "google.com"...domain server (8.8.8.8) [OK] #3 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 172.217.161.46, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 8/8/9 ms #4 #1 R1 fails to resolve google.com. #2 Configures 8.8.8.8 as R1’s DNS server #3 The domain name is successfully resolved. #4 The ping works.
Compare failed hostname resolution before configuration with successful resolution and ping afterward. section 3.2.1
