Linux hosting DNS settings connect your domain name to an IP address so your website can be reached. The Domain Name System (DNS) is a critical part of the internet that maps domain names to IP addresses. Properly configured DNS settings ensure your site remains available, fast and reliable.
This article explains the necessary steps to configure DNS settings on Linux hosting, covering common record types and practical examples for BIND and other name server setups.
What is DNS and Why Is It Important?
DNS translates a human-readable domain name into a server’s IP address. When a user enters a domain into a browser, DNS servers resolve that name to the corresponding IP address to establish the connection. If DNS is misconfigured on your Linux hosting environment, your site can become unavailable or route to the wrong server.
Common DNS Record Types on Linux Hosting
Before editing DNS settings, it is important to understand the main record types you will work with:
- A Record (Address Record) — points a domain to an IPv4 address.
- AAAA Record — points a domain to an IPv6 address.
- CNAME Record (Canonical Name) — aliases one domain to another.
- MX Record (Mail Exchange) — designates the mail server handling email for the domain.
- TXT Record (Text Record) — used for domain verification and security settings such as SPF, DKIM and DMARC.
- NS Record (Name Server) — indicates which DNS servers are authoritative for the domain.
- SRV Record (Service Record) — used for locating services such as VoIP or messaging servers.
Configuring DNS Settings on Linux Hosting
A Record (Pointing a Domain to an IP Address)
To edit DNS settings on your Linux server, connect via SSH and ensure a DNS server (like BIND) is installed. Typical steps include:
ssh root@your-server-ip
Install BIND if it is not already present:
sudo apt update && sudo apt install bind9 -y # Debian/Ubuntu
sudo yum install bind -y # CentOS/RHEL
Open your DNS configuration file (paths vary by distribution):
sudo nano /etc/bind/named.conf.local
# or
sudo nano /etc/named.conf
Create or edit the zone file for your domain, for example:
sudo nano /etc/bind/db.example.com
# or
sudo nano /var/named/example.com.zone
Example A record entries:
example.com. IN A 192.168.1.100
www IN A 192.168.1.100
Restart the DNS service to apply changes:
sudo systemctl restart bind9 # Debian/Ubuntu
sudo systemctl restart named # CentOS/RHEL
MX Record (Email Server Routing)
If you need to route email for your domain, add an MX record to the domain zone file. Open the zone file and add entries such as:
example.com. IN MX 10 mail.example.com.
mail IN A 192.168.1.200
Save the file and restart the DNS service. This configuration directs example.com email traffic to mail.example.com.
CNAME Record (Alias One Domain to Another)
Use a CNAME record to point a subdomain at another domain. In your zone file, add a CNAME entry like:
blog IN CNAME example.com.
Restart the DNS service so the alias takes effect. For example, blog.example.com will then resolve to example.com.
TXT Record (Verification and Email Security)
TXT records are used for domain verification and email security protocols such as SPF, DKIM and DMARC. An example SPF record looks like this:
example.com. IN TXT "v=spf1 include:_spf.google.com ~all"
After adding TXT records, restart the DNS server to enable the updates. Proper TXT records help prevent email spoofing and improve deliverability.
Testing DNS Settings
Verify your DNS configuration with the following diagnostic commands:
- For a local server lookup:
nslookup example.com - To query a specific DNS server:
dig example.com @8.8.8.8 - To check MX records:
dig MX example.com
If you encounter errors, check DNS-related logs to locate issues:
sudo tail -f /var/log/syslog # Debian/Ubuntu
sudo tail -f /var/log/messages # CentOS/RHEL
Properly configuring DNS on Linux hosting improves site availability, security and user experience. Correct domain routing, email server settings, subdomain configuration and security records together reduce errors and ensure reliable operation. If you face persistent problems, clearing caches and reviewing logs typically helps quickly identify and resolve misconfigurations.