### Comprehensive Tutorial on Setting IOS DNS Servers
In this tutorial, we will learn how to configure DNS servers on a Cisco IOS device. DNS (Domain Name System) is crucial for resolving hostnames to IP addresses, allowing devices to communicate with one another over a network. We'll cover configuring both the DNS server settings on the router and testing the configuration.
#### Prerequisites
- Access to a Cisco IOS device (router or switch) with terminal access (CLI).
- Basic knowledge of Cisco IOS commands.
### Step 1: Access the Device
Connect to your Cisco IOS device using a console cable or SSH, and enter privileged EXEC mode.
```plaintext
Router> enable
Router#
```
### Step 2: Enter Global Configuration Mode
To change the DNS settings, you need to enter global configuration mode.
```plaintext
Router# configure terminal
Router(config)#
```
### Step 3: Set the DNS Server
Use the following command to specify the IP address of your DNS server. You can set multiple DNS servers by repeating the command with different IP addresses.
```plaintext
Router(config)# ip name-server <dns-server-ip>
```
**Example**: Setting a primary DNS server to `8.8.8.8` (Google DNS):
```plaintext
Router(config)# ip name-server 8.8.8.8
```
**Example**: Setting a secondary DNS server to `8.8.4.4`:
```plaintext
Router(config)# ip name-server 8.8.4.4
```
### Step 4: Configure the Domain Name
You can also set a default domain name for the router, which will be appended to any unqualified hostnames.
```plaintext
Router(config)# ip domain-name <domain-name>
```
**Example**: Setting the domain name to `example.com`:
```plaintext
Router(config)# ip domain-name example.com
```
### Step 5: Enable DNS Lookup (Optional)
By default, DNS lookup is enabled on Cisco IOS devices. If it has been disabled for some reason, you can enable it using:
```plaintext
Router(config)# ip dns lookup
```
### Step 6: Exit Configuration Mode
Once you have configured the DNS settings, exit global configuration mode.
```plaintext
Router(config)# exit
Router#
```
### Step 7: Save the Configuration
To ensure that the configuration persists after a reboot, save the changes to the startup configuration.
```plaintext
Router# write memory
```
or
```plaintext
Router# copy running-config startup-config
```
### Step 8: Verify the Configuration
You can verify the DNS settings using the following commands:
1. **Check the configured DNS servers**:
```plaintext
Router# show ip name-server
```
**Expected Output**:
```plaintext
ip name-server 8.8.8.8
ip name-server 8.8.4.4
```
2. **Check the domain name**:
```plaintext
Router# show running-config | include domain-name
```
**Expected Output**:
```plaintext
ip domain-name example.com
```
### Step 9: Testing DNS Resolution
You can test the DNS configuration by using the `ping` command with a hostname to see if it resolves correctly.
```plaintext
Router# ping www.example.com
```
**Expected Output**:
If the DNS configuration is correct, you should see a response indicating successful pings:
```plaintext
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to <resolved-ip-address>, timeout is 2 seconds:
!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/30/40 ms
```
### Step 10: Troubleshooting
If DNS resolution is not working, consider the following troubleshooting steps:
1. **Verify the DNS server IP addresses**: Ensure they are correct and reachable.
```plaintext
Router# ping <dns-server-ip>
```
2. **Check the interface configuration**: Make sure the router's interfaces are up and have the correct IP addresses assigned.
3. **Check for ACLs or firewalls**: Ensure there are no access control lists (ACLs) or firewalls blocking DNS queries.
4. **Use debug commands**: If you need more insight, you can enable debugging for DNS:
```plaintext
Router# debug ip dns
```
### Conclusion
In this tutorial, you have learned how to set DNS servers on a Cisco IOS device, configure the domain name, verify the settings, and test DNS resolution. Proper DNS configuration is essential for efficient network communication. If you have further questions or need clarification, feel free to ask!
Rate This Article
Thanks for reading: Setting IOS DNS Servers Tutorial, Sorry, my English is bad:)