# DNS 101

## Defining hosts and domains locally

To define a static host name to address mapping, use the following command:

```
R(config)# ip host NAME [TELNET-PORT] ADDRESS
```

For hosts that are accessed without a domain name at the end, (hostname.domain-name), you can define a default domain name or a list of domain names to be used, using one of the following commands:

```
R(config)# ip domain name DOMAIN
R(config)# ip domain list DOMAIN
! Domain list is preferred over domain name. 
```

## Using a DNS Server

To define a DNS server and make the router work as a DNS client, use:

```
R(config)# ip name-server SERVER1 [SERVER2 ...]
```

The local mappings will be used first, and if there is no match, the name-server will be queried.

For DNS lookups you can define:

```
R(config)# ip domain timeout SEC
R(config)# ip domain retry NUMBER
```

By default, if there are multiple DNS servers defined, the first one will be used by default, while the other servers will only be used in case of failure of the previous servers.\
For one host a router can have multiple IP addresses that it is resolved to. By default, only the first one is used. You can use each IP address in a round-robin fashion if you enable

```
R(config)# ip domain round-robin
```

To see the current dns cache, use:

```
R# show ip hosts
```

Of course, lookups can be disabled altogether, using:

```
R(config)# no ip domain-lookup
```

## Making the router a DNS Server

To configure the router as a server, use:

```
R(config)# ip dns server
```

The router will respond to DNS requests with data from its statically configured hosts or from the responses cached from the other DNS servers.

DNS Spoofing is an option that is enabled only if the domain lookups are disabled, if no name servers are configured, or if there is no route to them. The router will respond to all DNS requests with the configured IP or with the interface IP:

```
R(config)# ip dns spoofing [IP-ADDRESS]
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ccie.nyquist.eu/ipv4/ipv4-addressing/dns-101.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
