Cisco Configurar serviço de DNS

In some scenarios, it may be beneficial to have your Cisco router act as a DNS server, handling DNS queries directly. This can simplify network management by centralizing DNS resolution or providing a fallback solution when external DNS servers are unreachable.

Here’s a step-by-step guide on configuring your Cisco router to function as a DNS server.


Why Configure DNS on a Cisco Router?

  1. Centralized DNS Management: All DNS traffic in your network can be routed through a single device.
  2. Custom Local Domains: Easily resolve internal hostnames (e.g., printer.local) without needing a fully qualified domain name (FQDN).
  3. Backup for External DNS Failures: The router can act as a secondary resolver if your primary DNS servers are inaccessible.

Step 1: Prepare the DNS Server Addresses

Before starting, identify the DNS servers your router will use to resolve external domains. These are typically provided by your ISP or can be public servers such as Google’s DNS (8.8.8.8 and 8.8.4.4).

For this example, we’ll use these public DNS addresses.


Step 2: Access the Router and Enter Configuration Mode

  1. Connect to the router via SSH, console, or other management methods.
  2. Enter configuration mode by executing:
    enable configure terminal

Step 3: Set the Upstream DNS Servers

Configure the DNS servers your router will use to fetch DNS information:

ip name-server 8.8.8.8 8.8.4.4

Replace 8.8.8.8 and 8.8.4.4 with the DNS server IP addresses you wish to use.


Step 4: Enable the DNS Server on the Router

Activate the router’s DNS server functionality:

ip dns server

This command enables the router to handle DNS queries from devices on your network.


Step 5: Configure a Primary Domain (Optional)

If you want the router to respond to queries for a local domain (e.g., office.local), set up the primary domain:

ip dns primary office.local

This setup allows the router to resolve hostnames such as machine1 or printer without requiring the full domain name (machine.office.local).


Example Configuration

Here’s a complete example where the router is configured to use Google’s DNS servers and respond to queries for the local domain office.local:

enable
configure terminal
ip name-server 8.8.8.8 8.8.4.4
ip dns server
ip dns primary office.local

Step 6: Testing the Configuration

  1. Verify the Name Servers:
    Check the configured DNS servers with:
    show running-config | include ip name-server
  2. Test DNS Queries:
    Use a device in your network to query the router for a DNS resolution. For example, use the ping command to test hostname resolution:
    ping machine1 

    If configured correctly, the router will resolve the hostname and respond with the appropriate IP address.

Additional Considerations

  • Caching: Cisco routers cache DNS queries for faster resolution. Ensure sufficient memory is available if you expect a high query volume.
  • Security: Limit DNS access to trusted internal devices by implementing ACLs.
  • Redundancy: Configure multiple upstream DNS servers to ensure reliability in case one server is unreachable.

By following these steps, your Cisco router can efficiently handle DNS queries, streamline local hostname resolution, and provide a backup DNS solution for your network.