Previous section   Next section

Recipe 2.10 Disabling Domain Name Lookups

2.10.1 Problem

You want to prevent your router from trying to connect to your typing errors.

2.10.2 Solution

To prevent the router from attempting to resolve typing errors, use the ip domain-lookup command:

Router1#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
Router1(config)#no ip domain-lookup 
Router1(config)#end
Router1#

You can also prevent the router from trying to resolve typing errors on routers that use DNS by changing the default EXEC behavior for unknown commands:

Router1#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
Router1(config)#line vty 0 4
Router1(config-line)#transport preferred none
Router1(config-line)#end
Router1#

2.10.3 Discussion

As we mentioned in Recipe 2.9, routers will attempt to resolve all hostnames using DNS by default. Unfortunately, if you don't configure a valid DNS name server, the router will send these queries to the local broadcast IP address, 255.255.255.255. Querying a nonexistent name server is not only unproductive, but it can also be quite time consuming. If this happens in an interactive session, the router will not return the EXEC prompt until the query times out. This can be quite frustrating because, by default, the router interprets any unknown command as a hostname that you want to connect to and attempts to resolve any typing mistakes you enter on the command line:

Router1#pnig
Translating "pnig"...domain server (255.255.255.255)
   
Translating "pnig"...domain server (255.255.255.255)
 (255.255.255.255)
Translating "pnig"...domain server (255.255.255.255)
% Unknown command or computer name, or unable to find computer address
Router1#

As you can see, we accidentally mistyped the command ping. The router did not know this command, assumed that it must be the name of a foreign host, and attempted to resolve it. Everybody who has used a Cisco router for more than a few minutes is familiar with this problem: the annoyance of a typing error is compounded by having to wait several seconds for the name query to time out.

One easy way to prevent this from happening is to disable DNS lookups, as we did in our first example:

Router1(config)#no ip domain-lookup

This is an effective solution if you don't need to use DNS services on the router. With name resolution disabled, the router still interprets our typing mistakes as names of foreign hosts, but will only attempt to resolve names from the static host entries. These entries don't need to time out, so the router will return your prompt immediately and allow you to enter the command you intended to type:

Router1#pnig
Translating "pnig"
% Unknown command or computer name, or unable to find computer address
Router1#

Routers that are properly configured to use DNS services, as in Recipe 2.9, will also attempt to resolve your typing errors by default. Because there is a real server to respond to the request and definitively state that there is no such host, the delay is somewhat shorter. The router queries each of the configured name servers in order until it receives a response or gives up trying:

Router1#pnig
Translating "pnig"...domain server (172.25.1.1) (10.1.20.5)
% Unrecognized host or address, or protocol not running.
   
Router1#

This is still an extremely inefficient way of handling typing errors, and, if you need to use DNS, the solution given in our first example is not practical. Let's attack the problem from a different angle.

The router attempts to resolve typing errors because, by default, every VTY line has a preferred transport method of Telnet. This means that you can initiate a Telnet session by typing a hostname at the prompt. You don't need to explicitly issue the telnet command. Therefore, when we type in "pnig" the router interprets this as "telnet pnig". However, if we set the preferred transport method to "none," the router won't try to connect to a remote device unless we explicitly issue the telnet command:

Router1(config)#line vty 0 4
Router1(config-line)#transport preferred none

This solves the problem by preventing the router from misinterpreting our typos as hostnames in the first place:

Router1#pnig
         ^
% Invalid input detected at '^' marker.
   
Router1#

The router now interprets the typing error as an invalid command rather than a hostname. We recommend using this solution to the problem because it doesn't prevent you from using DNS.

2.10.4 See Also

Recipe 2.8; Recipe 2.9


  Previous section   Next section
Top