{"id":6721,"date":"2026-06-03T12:17:58","date_gmt":"2026-06-03T12:17:58","guid":{"rendered":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/?p=6721"},"modified":"2026-06-03T06:50:09","modified_gmt":"2026-06-03T06:50:09","slug":"how-to-configure-a-dns-server-in-linux","status":"publish","type":"post","link":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/509\/configure-dns-server-in-linux.html","title":{"rendered":"How to Configure a DNS Server in Linux\u200b?"},"content":{"rendered":"\n<p>A properly configured DNS server is one of the most important yet often overlooked parts of a Linux system. Whether you are managing a web server, VPS, dedicated server, or internal network, DNS settings directly impact domain resolution, application connectivity, software updates, email delivery, and overall system reliability.<\/p>\n\n\n\n<p>If DNS is configured incorrectly, even a perfectly functioning server can experience connectivity issues, package installation failures, and service disruptions.&nbsp;<\/p>\n\n\n\n<p>In this guide, we will walk through configuring DNS servers on Linux using two different methods, understand when each method should be used, and verify that everything is working correctly after configuration.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<p><strong>Also Read: <\/strong><a href=\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/502\/how-to-clear-dns-cache-html\"><strong>How to Clear DNS Cache?<\/strong><\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Understanding DNS Configuration Files in Linux<\/strong><\/h2>\n\n\n\n<p>Depending on your Linux distribution, DNS settings are generally stored in:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n                <td class=\"kb_firewall\"><strong><strong>AddType text\/html .shtml<br>AddHandler server-parsed.shtml<br>Options +Includes\n<\/strong><\/strong><\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n\n\n\n<p>This file contains the DNS servers your system uses for domain name resolution.<\/p>\n\n\n\n<p><strong>A typical entry looks like:<\/strong><\/p>\n\n\n\n<p><strong>nameserver 8.8.8.8<\/strong><\/p>\n\n\n\n<p><strong>nameserver 8.8.4.4<\/strong><\/p>\n\n\n\n<p><strong>Here:<\/strong><\/p>\n\n\n\n<ul style=\"margin-left: 24px;\">\n    <li><strong>8.8.8.8<\/strong> = Google Public DNS<\/li>\n    <li><strong>8.8.4.4<\/strong> = Secondary Google DNS<\/li>\n<\/ul>\n\n\n\n<div style=\"border: 1px solid #faf4ff; padding: 18px 24px; background-color: #faf4ff; width: 730px;\">\n  <p style=\"margin: 0 0 10px 0;\">\n    <strong>\u2605 Quick Tip<\/strong>\n  <\/p>\n\n  <p style=\"margin: 0 0 10px 0;\">\n   Always configure at least two DNS servers.\n  <\/p>\n\n  <p style=\"margin: 0;\">\n    If the primary DNS server becomes unavailable, your system can automatically use the secondary server, improving reliability.\n  <\/p>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<p><strong>Also Read: <\/strong><a href=\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/501\/fix-slow-dns-lookup-html\"><strong>How to Fix Slow DNS Lookup?<\/strong><\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Before You Start<\/strong><\/h2>\n\n\n\n<p><strong>Before configuring DNS settings:<\/strong><\/p>\n\n\n\n<ul style=\"margin-left: 24px;\">\n    <li>Ensure you have root or sudo access.<\/li>\n    <li>Verify your internet connection.<\/li>\n    <li>Identify the DNS servers you want to use.<\/li>\n<\/ul>\n\n\n\n<p><strong>Common public DNS servers include:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Provider<\/strong><\/td><td><strong>Primary DNS<\/strong><\/td><td><strong>Secondary DNS<\/strong><\/td><\/tr><tr><td>Google DNS<\/td><td>8.8.8.8<\/td><td>8.8.4.4<\/td><\/tr><tr><td>Cloudflare DNS<\/td><td>1.1.1.1<\/td><td>1.0.0.1<\/td><\/tr><tr><td>OpenDNS<\/td><td>208.67.222.222<\/td><td>208.67.220.220<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<p><strong>Also Read: <\/strong><a href=\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/507\/change-ssh-port-in-linux.html\"><strong>How to Change SSH Port in Linux?<\/strong><\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Methods to Configure DNS Server in Linux<\/strong><\/h2>\n\n\n\n<p style=\"margin-left: 24px;\">\n  <strong style=\"font-size: 18px;\">\u27a2 Method 1: Configure DNS Using \/etc\/resolv.conf<\/strong>\n<\/p>\n\n\n\n<p>This is the simplest and most direct method.<\/p>\n\n\n\n<p style=\"margin-left:24px;\">\n  \u2794 Open the DNS Configuration File &#038; run:\n<\/p>\n\n\n\n<figure class=\"wp-block-table\"><button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n                <td class=\"kb_firewall\"><strong><strong>sudo nano \/etc\/resolv.conf\n<\/strong><\/strong><\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n\n\n\n<p>This file tells Linux which DNS servers to use for domain name lookups, and opening the file allows us to add or modify DNS entries.<\/p>\n\n\n\n<p style=\"margin-left:24px;\">\n  \u2794 Now, you have to add DNS server entries by adding the following lines:\n<\/p>\n<figure class=\"wp-block-table\"><button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n                <td class=\"kb_firewall\"><strong><strong>nameserver 8.8.8.8<br>\nnameserver 8.8.4.4\n<\/strong><\/strong><\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n<p style=\"margin-left:24px;\">\n  \u2794 After adding, just save the file and exit.\n<\/p>\n\n\n\n<p>This instructs Linux to query Google&#8217;s DNS servers whenever a domain name needs to be resolved.<\/p>\n\n\n\n<p style=\"margin-left:24px;\">\n  \u2794 Now, it\u2019s time to test DNS resolution by running the following command\n<\/p>\n\n\n\n<figure class=\"wp-block-table\"><button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n                <td class=\"kb_firewall\"><strong><strong>ping google.com\n<\/strong><\/strong><\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n\n\n\n<p>This confirms that your system can successfully convert domain names into IP addresses using the configured DNS server.<\/p>\n\n\n\n<div style=\"border: 1px solid #faf4ff; padding: 18px 24px; background-color: #faf4ff; width: 730px;\">\n  <p style=\"margin: 0 0 10px 0;\">\n    <strong>\u2605 Quick Tip<\/strong>\n  <\/p>\n\n  <p style=\"margin: 0 0 10px 0;\">\n   If domain names do not resolve but IP addresses work, DNS configuration is often the first thing to check.\n  <\/p>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<p><strong>Also Read: <\/strong><a href=\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/498\/setup-ftp-on-linux-server.html\"><strong>How to Set Up FTP on Linux\u200b?<\/strong><\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<p style=\"margin-left: 24px;\">\n  <strong style=\"font-size: 18px;\">\u27a2 Method 2: Configure a DNS Server in Linux Using BIND9<\/strong>\n<\/p>\n\n\n\n<p>BIND9 (Berkeley Internet Name Domain 9) is one of the most widely used DNS server software solutions for Linux, trusted by organizations and hosting providers worldwide.&nbsp;<\/p>\n\n\n\n<p>It allows you to host your own DNS zones, manage domain records, and control how DNS queries are resolved within your network or on the internet.<\/p>\n\n\n\n<p><strong>Step 1: Install BIND9<\/strong><\/p>\n\n\n\n<p style=\"margin-left:24px;\">\n  \u2794 First, update your package repository and install BIND9:\n<\/p>\n\n\n\n<figure class=\"wp-block-table\"><button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n                <td class=\"kb_firewall\"><strong><strong>sudo apt update<br>\nsudo apt install bind9 bind9utils bind9-doc -y\n\n<\/strong><\/strong><\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n\n\n\n<div style=\"border: 1px solid #faf4ff; padding: 18px 24px; background-color: #faf4ff; width: 730px; margin-top:16px;\">\n  <p style=\"margin: 0 0 10px 0;\">\n    <strong>\u2605 Quick Tip<\/strong>\n  <\/p>\n\n  <p style=\"margin: 0 0 10px 0;\">\nBefore proceeding, ensure your server has a static IP address. DNS servers should ideally use a fixed IP so clients can always reach them.  <\/p>\n<\/div>\n\n\n\n<p style=\"margin-top:16px;\"><strong>Step 2: Verify BIND9 Installation<\/strong><\/p>\n\n\n\n<p>Forwarders allow your DNS server to send unresolved queries to upstream DNS providers such as Google DNS instead of performing full recursive lookups itself.<\/p>\n\n\n\n<p style=\"margin-left:24px;\">\n  \u2794 Now, you have to check whether the BIND9 service is running:\n<\/p>\n<figure class=\"wp-block-table\"><button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n                <td class=\"kb_firewall\"><strong><strong>sudo systemctl status bind9\n<\/strong><\/strong><\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n\n\n\n<p>After running, you should see:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n                <td class=\"kb_firewall\"><strong><strong>sudo systemctl status bind9\n<\/strong><\/strong><\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n\n\n\n<p><strong>Step 3: Configure Forwarders<\/strong><\/p>\n\n\n\n<p style=\"margin-left:24px;\">\n  \u2794 Open the BIND options file:\n<\/p>\n<figure class=\"wp-block-table\"><button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n                <td class=\"kb_firewall\"><strong><strong>sudo nano \/etc\/bind\/named.conf.options\n<\/strong><\/strong><\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n<p style=\"margin-left:24px;\">\n  \u2794 Locate the <strong>forwarders<\/strong> section and update it:\n<\/p>\n\n\n\n<figure class=\"wp-block-table\">\n    <button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button>\n    <span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n                <td class=\"kb_firewall\">\n<strong>options {<\/strong><br>\n&nbsp;&nbsp;&nbsp;&nbsp;directory &#8220;\/var\/cache\/bind&#8221;;<br><br>\n\n&nbsp;&nbsp;&nbsp;&nbsp;forwarders {<br>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;8.8.8.8;<br>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;8.8.4.4;<br>\n&nbsp;&nbsp;&nbsp;&nbsp;};<br><br>\n\n&nbsp;&nbsp;&nbsp;&nbsp;dnssec-validation auto;<br>\n&nbsp;&nbsp;&nbsp;&nbsp;listen-on { any; };<br>\n<strong>};<\/strong>\n                <\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n\n\n\n<p>Once done, save and close the file.<\/p>\n\n\n\n<p><strong>Step 4: Create a DNS Zone<\/strong><\/p>\n\n\n\n<p>A DNS zone tells BIND which domain it is responsible for managing.<\/p>\n\n\n\n<p style=\"margin-left:24px;\">\n  \u2794 You have to edit the local zones configuration file:\n<\/p>\n<figure class=\"wp-block-table\">\n    <button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button>\n    <span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n                <td class=\"kb_firewall\"><strong>sudo nano \/etc\/bind\/named.conf.local<\/strong><\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n\n\n\n<p style=\"margin-left:24px;\">\n  \u2794 You have to add:\n<\/p>\n<figure class=\"wp-block-table\">\n    <button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button>\n    <span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n               <td class=\"kb_firewall\">\n    zone &#8220;example.com&#8221; {<br>\n    &nbsp;&nbsp;&nbsp;&nbsp;type master;<br>\n    &nbsp;&nbsp;&nbsp;&nbsp;file &#8220;\/etc\/bind\/zones\/db.example.com&#8221;;<br>\n    };\n<\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n\n\n\n<p>eplace <strong>example.com<\/strong> with your actual domain.<\/p>\n\n\n\n<p><strong>Step 5: Create a Zone Directory<\/strong><\/p>\n\n\n\n<p>Keeping zone files in a separate directory improves organization and simplifies management as additional domains are added.<\/p>\n\n\n\n<p>Create a dedicated directory for zone files:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n                <td class=\"kb_firewall\"><strong><strong>sudo mkdir \/etc\/bind\/zones\n<\/strong><\/strong><\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n\n\n\n<p><strong>Step 6: Create the Forward Zone File<\/strong><\/p>\n\n\n\n<p>The zone file contains the actual DNS records that clients will query, such as A records, NS records, and mail server entries.<\/p>\n\n\n\n<p style=\"margin-left:24px;\">\n  \u2794 You have to copy the default template:\n<\/p>\n\n\n\n<figure class=\"wp-block-table\"><button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n                <td class=\"kb_firewall\"><strong><strong>sudo cp \/etc\/bind\/db.local \/etc\/bind\/zones\/db.example.com\n<\/strong><\/strong><\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n\n\n\n<p style=\"margin-left:24px;\">\n  \u2794 You have to edit the file:\n<\/p>\n<figure class=\"wp-block-table\"><button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n                <td class=\"kb_firewall\"><strong><strong>sudo nano \/etc\/bind\/zones\/db.example.com\n<\/strong><\/strong><\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n\n\n\n<p><strong>Example configuration:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\">\n    <button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button>\n    <span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n                <td class=\"kb_firewall\">\n                    $TTL 86400<br><br>\n\n                    @ IN SOA ns1.example.com. admin.example.com. (<br>\n                    &nbsp;&nbsp;&nbsp;&nbsp;2026060101<br>\n                    &nbsp;&nbsp;&nbsp;&nbsp;3600<br>\n                    &nbsp;&nbsp;&nbsp;&nbsp;1800<br>\n                    &nbsp;&nbsp;&nbsp;&nbsp;604800<br>\n                    &nbsp;&nbsp;&nbsp;&nbsp;86400 )<br><br>\n\n                    @&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IN NS ns1.example.com.<br>\n                    ns1&nbsp;&nbsp;&nbsp;IN A 192.168.1.10<br>\n                    @&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IN A 192.168.1.10<br>\n                    www&nbsp;&nbsp;&nbsp;IN A 192.168.1.10<br>\n                    mail&nbsp;&nbsp;IN A 192.168.1.20\n                <\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n\n\n\n<div style=\"border: 1px solid #faf4ff; padding: 18px 24px; background-color: #faf4ff; width: 730px;\">\n  <p style=\"margin: 0 0 10px 0;\">\n    <strong>\u2605 Quick Tip<\/strong>\n  <\/p>\n\n  <p style=\"margin: 0 0 10px 0;\">\nWhenever you make changes to a zone file, increase the Serial Number. This helps secondary DNS servers recognize that updates are available.<\/p>\n<\/div>\n\n\n\n<p style=\"margin-top:16px;\"><strong>Step 7: Validate Configuration Files<\/strong><\/p>\n\n\n\n<p>Validation helps identify syntax errors before restarting the DNS service, preventing unnecessary downtime.<\/p>\n\n\n\n<p style=\"margin-left:24px;\">\n  \u2794 You have to check the main BIND configuration:\n<\/p>\n\n\n\n<figure class=\"wp-block-table\"><button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n                <td class=\"kb_firewall\"><strong><strong>sudo named-checkconf\n<\/strong><\/strong><\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n\n\n\n<p style=\"margin-left:24px;\">\n  \u2794 Validate the zone file:\n<\/p>\n<figure class=\"wp-block-table\"><button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n                <td class=\"kb_firewall\"><strong><strong>sudo named-checkzone example.com \/etc\/bind\/zones\/db.example.com\n<\/strong><\/strong><\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n\n\n\n<p style=\"margin-left:24px;\">\n  \u2794 Once done, your expected output would be:\n<\/p>\n<figure class=\"wp-block-table\"><span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n                <td class=\"kb_firewall\"><strong><strong>OK\n<\/strong><\/strong><\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n\n\n\n<p><strong>Step 8: Restart BIND9<\/strong><\/p>\n\n\n\n<p>Restarting BIND9 reloads all DNS zones and configuration files into memory.<\/p>\n\n\n\n<p style=\"margin-left:24px;\">\n  \u2794 Now, you have to apply the new configuration:\n<\/p>\n<figure class=\"wp-block-table\"><button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n                <td class=\"kb_firewall\"><strong><strong>sudo systemctl restart bind9\n<\/strong><\/strong><\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n\n\n\n<p style=\"margin-left:24px;\">\n  \u2794 Verify service status:\n<\/p>\n<figure class=\"wp-block-table\"><button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n                <td class=\"kb_firewall\"><strong><strong>sudo systemctl status bind9\n<\/strong><\/strong><\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n\n\n\n<p><strong>Step 9: Allow DNS Through Firewall<\/strong><\/p>\n\n\n\n<p>If your Linux server has a firewall enabled (such as UFW), you must allow DNS traffic so that other devices can send DNS requests to your BIND9 server.<\/p>\n\n\n\n<p><strong>Run the following commands:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n                <td class=\"kb_firewall\"><strong><strong>sudo ufw allow 53\/tcp<br>\nsudo ufw allow 53\/udp\n<\/strong><\/strong><\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n\n\n\n<p><strong>Step 10: Test DNS Resolution<\/strong><\/p>\n\n\n\n<p>Testing confirms that BIND9 is responding correctly and serving records from your zone file.<\/p>\n\n\n\n<p style=\"margin-left:24px;\">\n  \u2794 Install DNS utilities if required:\n<\/p>\n<figure class=\"wp-block-table\"><button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n                <td class=\"kb_firewall\"><strong><strong>sudo apt install dnsutils -y\n<\/strong><\/strong><\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n\n\n\n<p style=\"margin-left:24px;\">\n  \u2794 Now, test your DNS server:\n<\/p>\n<figure class=\"wp-block-table\"><button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n                <td class=\"kb_firewall\"><strong><strong>nslookup example.com localhost\n<\/strong><\/strong><\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<p><strong>Also Read: <\/strong><a href=\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/494\/change-root-password-in-linux.html\"><strong>How to Change Root Password in Linux?<\/strong><\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Small Administrator Tips<\/strong><\/h2>\n\n\n\n<p style=\"margin-left:24px;\">\n  \u2794 Always keep a backup of your zone files before making changes.\n<\/p>\n<p style=\"margin-left:24px;\">\n  \u2794 Use meaningful hostnames such as ns1, mail, and www.\n<\/p>\n<p style=\"margin-left:24px;\">\n  \u2794 Regularly monitor logs:\n<\/p>\n\n\n\n<figure class=\"wp-block-table\"><button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n    <table class=\"has-fixed-layout\">\n        <tbody>\n            <tr>\n                <td class=\"kb_firewall\"><strong><strong>sudo journalctl -u bind9\n<\/strong><\/strong><\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/figure>\n\n\n\n<p style=\"margin-left:24px;\">\n  \u2794 Keep BIND9 up to date to receive security patches and performance improvements.\n<\/p>\n<p style=\"margin-left:24px;\">\n  \u2794 If hosting public DNS, use proper DNSSEC and access controls for enhanced security.\n<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<p><strong>Also Read: <\/strong><a href=\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/486\/kill-process-in-linux.html\"><strong>How to Kill a Process in Linux?<\/strong><\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>Configuring a DNS server in Linux is more than just pointing a system to a nameserver; it is about ensuring reliable communication between users, applications, and services. In this guide, we have covered both effective approaches: configuring DNS resolution via <strong>\/etc\/resolv.conf<\/strong> and setting up a dedicated DNS server using BIND9 to host and manage your own DNS records.<\/p>\n\n\n\n<p>While updating <strong>\/etc\/resolv.conf<\/strong> helps a Linux system resolve domain names using external DNS servers, and BIND9 gives you complete control over DNS management, allowing you to create zones, manage records, and serve DNS requests for your domains. Together, these methods provide the foundation needed to build a stable and efficient DNS environment.<\/p>\n\n\n\n<p>As you continue managing your Linux server, remember to validate configuration changes, test DNS resolution after every update, and keep your DNS records organized and up to date. A properly configured DNS server not only improves network reliability but also ensures that websites, applications, and email services operate smoothly without interruption.<\/p>\n\n\n\n<script>\nfunction copyCommand(btn) {\n  const td = btn.parentElement.querySelector(\"td.kb_firewall\");\n  const text = td.innerText.trim();\n\n  navigator.clipboard.writeText(text).then(() => {\n    const msg = btn.parentElement.querySelector(\".copy-msg\");\n    msg.style.display = \"inline-block\";\n    setTimeout(() => msg.style.display = \"none\", 1000);\n  });\n}\n<\/script>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A properly configured DNS server is one of the most important yet often overlooked parts of a Linux system. Whether you are managing a web server, VPS, dedicated server, or internal network, DNS settings directly impact domain resolution, application connectivity, software updates, email delivery, and overall system reliability. If DNS is configured incorrectly, even a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[],"class_list":["post-6721","post","type-post","status-publish","format-standard","hentry","category-vps"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Configure a DNS Server in Linux\u200b?<\/title>\n<meta name=\"description\" content=\"Learn to configure a DNS server in Linux using BIND9 and \/etc\/resolv.conf by following step-by-step instructions to set up, manage, &amp; verify DNS configuration.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/509\/configure-dns-server-in-linux.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Configure a DNS Server in Linux\u200b?\" \/>\n<meta property=\"og:description\" content=\"Learn to configure a DNS server in Linux using BIND9 and \/etc\/resolv.conf by following step-by-step instructions to set up, manage, &amp; verify DNS configuration.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/509\/configure-dns-server-in-linux.html\" \/>\n<meta property=\"og:site_name\" content=\"Host IT Smart Knowledge base\" \/>\n<meta property=\"article:published_time\" content=\"2026-06-03T12:17:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-03T06:50:09+00:00\" \/>\n<meta name=\"author\" content=\"Admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/509\/configure-dns-server-in-linux.html\",\"url\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/509\/configure-dns-server-in-linux.html\",\"name\":\"How to Configure a DNS Server in Linux\u200b?\",\"isPartOf\":{\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#website\"},\"datePublished\":\"2026-06-03T12:17:58+00:00\",\"dateModified\":\"2026-06-03T06:50:09+00:00\",\"author\":{\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/317c14a877385667f19d3b7496bd5108\"},\"description\":\"Learn to configure a DNS server in Linux using BIND9 and \/etc\/resolv.conf by following step-by-step instructions to set up, manage, & verify DNS configuration.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/509\/configure-dns-server-in-linux.html\"]}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#website\",\"url\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/\",\"name\":\"Host IT Smart Knowledge base\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/317c14a877385667f19d3b7496bd5108\",\"name\":\"Admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d4827c56a6721070dde339640d47ff44ba0d0e515c7e577cf29305ab72383fe3?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d4827c56a6721070dde339640d47ff44ba0d0e515c7e577cf29305ab72383fe3?s=96&d=mm&r=g\",\"caption\":\"Admin\"},\"sameAs\":[\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/\"],\"url\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Configure a DNS Server in Linux\u200b?","description":"Learn to configure a DNS server in Linux using BIND9 and \/etc\/resolv.conf by following step-by-step instructions to set up, manage, & verify DNS configuration.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/509\/configure-dns-server-in-linux.html","og_locale":"en_US","og_type":"article","og_title":"How to Configure a DNS Server in Linux\u200b?","og_description":"Learn to configure a DNS server in Linux using BIND9 and \/etc\/resolv.conf by following step-by-step instructions to set up, manage, & verify DNS configuration.","og_url":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/509\/configure-dns-server-in-linux.html","og_site_name":"Host IT Smart Knowledge base","article_published_time":"2026-06-03T12:17:58+00:00","article_modified_time":"2026-06-03T06:50:09+00:00","author":"Admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Admin","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/509\/configure-dns-server-in-linux.html","url":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/509\/configure-dns-server-in-linux.html","name":"How to Configure a DNS Server in Linux\u200b?","isPartOf":{"@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#website"},"datePublished":"2026-06-03T12:17:58+00:00","dateModified":"2026-06-03T06:50:09+00:00","author":{"@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/317c14a877385667f19d3b7496bd5108"},"description":"Learn to configure a DNS server in Linux using BIND9 and \/etc\/resolv.conf by following step-by-step instructions to set up, manage, & verify DNS configuration.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/509\/configure-dns-server-in-linux.html"]}]},{"@type":"WebSite","@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#website","url":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/","name":"Host IT Smart Knowledge base","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/317c14a877385667f19d3b7496bd5108","name":"Admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d4827c56a6721070dde339640d47ff44ba0d0e515c7e577cf29305ab72383fe3?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d4827c56a6721070dde339640d47ff44ba0d0e515c7e577cf29305ab72383fe3?s=96&d=mm&r=g","caption":"Admin"},"sameAs":["https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/"],"url":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/posts\/6721","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/comments?post=6721"}],"version-history":[{"count":156,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/posts\/6721\/revisions"}],"predecessor-version":[{"id":6877,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/posts\/6721\/revisions\/6877"}],"wp:attachment":[{"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/media?parent=6721"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/categories?post=6721"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/tags?post=6721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}