Varidata News Bulletin
Knowledge Base | Q&A | Latest Technology | IDC Industry News
Knowledge-base

How to Configure DNS on Ubuntu Server?

Release Date: 2025-02-03

Configuring DNS (Domain Name System) settings on your Ubuntu server is a crucial step in optimizing network performance and ensuring reliable connectivity. Whether you’re managing a server hosting environment or fine-tuning your server’s Domain Name System configuration, this comprehensive guide will walk you through the process step by step. We’ll explore both temporary and permanent Domain Name System modification methods, focusing on practical implementations and performance optimization.

Understanding DNS and Its Impact on Server Performance

Before diving into the configuration process, it’s essential to understand why Domain Name System configuration matters. Domain Name System acts as the internet’s phonebook, translating domain names into IP addresses. A properly configured Domain Name System can significantly improve your server’s response time, reduce latency, and enhance overall network reliability.

Popular DNS providers for server environments include:

  • Google Public DNS (8.8.8.8, 8.8.4.4)
  • Cloudflare DNS (1.1.1.1, 1.0.0.1)
  • OpenDNS (208.67.222.222, 208.67.220.220)

Temporary DNS Configuration Methods

Let’s start with quick, temporary DNS modifications. These changes will revert after a system reboot but are useful for testing purposes.

Method 1: Using resolvectl command:


sudo resolvectl dns eth0 8.8.8.8 8.8.4.4
sudo resolvectl dnsovertls eth0 yes
sudo systemd-resolve --status

Method 2: Modifying resolv.conf:


sudo nano /etc/resolv.conf

# Add these lines
nameserver 8.8.8.8
nameserver 8.8.4.4

To verify your changes, use:


dig google.com | grep "SERVER"

Permanent DNS Configuration Methods

For persistent Domain Name System settings that survive system reboots, we’ll explore three robust approaches. These methods ensure your Domain Name System configuration remains consistent across server restarts.

1. Netplan Configuration (Modern Ubuntu Systems)

Netplan is Ubuntu’s default network configuration tool. Create or edit your configuration file:


sudo nano /etc/netplan/00-installer-config.yaml

# Add this configuration
network:
  version: 2
  ethernets:
    eth0:
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]
        search: [mydomain.com]
      dhcp4: true

Apply the changes with:


sudo netplan try
sudo netplan apply

2. Systemd-resolved Configuration

For more advanced setups, modify the systemd-resolved configuration:


sudo nano /etc/systemd/resolved.conf

[Resolve]
DNS=8.8.8.8 8.8.4.4
FallbackDNS=1.1.1.1 1.0.0.1
DNSOverTLS=yes
DNSSEC=allow-downgrade
DNSStubListener=yes

Restart the service to apply changes:


sudo systemctl restart systemd-resolved
sudo systemctl status systemd-resolved

3. Network Manager Method

For servers with Network Manager installed, use the nmcli command:


# View current connection name
nmcli connection show

# Modify DNS settings
sudo nmcli con mod "System eth0" ipv4.dns "8.8.8.8 8.8.4.4"
sudo nmcli con mod "System eth0" ipv4.ignore-auto-dns yes

# Apply changes
sudo nmcli con up "System eth0"

Performance Testing and Validation

After implementing DNS changes, it’s crucial to verify and benchmark your configuration:


# Test DNS resolution speed
time dig @8.8.8.8 google.com

# Check DNS configuration
systemd-resolve --status

# Monitor DNS queries
sudo tcpdump -i any port 53

Troubleshooting Common DNS Issues

When managing Domain Name System configurations on Ubuntu servers, you might encounter several common issues. Here’s how to address them systematically:

1. DNS Resolution Failures


# Clear DNS cache
sudo systemd-resolve --flush-caches

# Check DNS connectivity
dig +short google.com
ping -c 4 8.8.8.8

# Verify network interface status
ip addr show

2. Configuration Conflicts

If you’re experiencing conflicts between different Domain Name System configuration methods, follow this priority check:

  • Check if systemd-resolved is running and enabled
  • Verify Netplan configuration syntax
  • Ensure no conflicting entries in /etc/resolv.conf

DNS Performance Optimization Tips

Optimize your server’s Domain Name System performance with these advanced configurations:


# Enable DNS caching
sudo nano /etc/systemd/resolved.conf

[Resolve]
Cache=yes
DNSStubListener=yes
CacheFromLocalhost=no

Consider implementing these best practices:

  • Use geographically closer Domain Name System servers for reduced latency
  • Implement DNS round-robin for load balancing
  • Configure backup DNS servers for redundancy
  • Monitor DNS response times regularly

Conclusion

Proper Domain Name System configuration is fundamental for optimal Ubuntu server performance. Whether you’re managing a hosting environment or configuring a standalone server, implementing the right DNS settings can significantly impact your server’s reliability and speed. Remember to regularly test your Domain Name System configuration and keep it updated with the latest security practices.

By following this guide, you’ve learned how to configure Domain Name System settings on Ubuntu servers using various methods. From temporary modifications to permanent configurations, you now have the knowledge to implement and maintain robust Domain Name System settings that enhance your server’s networking capabilities.

Your FREE Trial Starts Here!
Contact our team for application of dedicated server service!
Register as a member to enjoy exclusive benefits now!
Your FREE Trial Starts here!
Contact our team for application of dedicated server service!
Register as a member to enjoy exclusive benefits now!
Telegram Skype