{"id":1807,"date":"2019-03-24T14:09:45","date_gmt":"2019-03-24T14:09:45","guid":{"rendered":"https:\/\/raspberrytips.com\/?p=1807"},"modified":"2026-02-19T05:54:12","modified_gmt":"2026-02-19T03:54:12","slug":"raspberry-pi-dns-server","status":"publish","type":"post","link":"https:\/\/raspberrytips.com\/raspberry-pi-dns-server\/","title":{"rendered":"How to Use Your Raspberry Pi as a DNS Server (Easy Guide)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I didn\u2019t expect much the first time I turned my Raspberry Pi into a DNS server, but it ended up being one of the simplest upgrades I\u2019ve made to my network. If you\u2019re curious about speeding up your browsing and learning how DNS really works, you\u2019re going to like this.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>DNSMasq is a service that can be installed on Raspberry Pi to answer DNS requests, the package is available in Raspberry Pi OS default repositories. It&#8217;s a free software that forwards the queries to other DNS servers and keep a local cache to speed up the process. <\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Below, you\u2019ll find everything you need to set this up: the installation steps on your Raspberry Pi, how to configure your computer to use it, and answers to common questions.<\/p>\n\n\n<style>.kb-table-of-content-nav.kb-table-of-content-id19563_c031ec-35 .kb-table-of-content-wrap{padding-top:var(--global-kb-spacing-sm, 1.5rem);padding-right:var(--global-kb-spacing-sm, 1.5rem);padding-bottom:var(--global-kb-spacing-sm, 1.5rem);padding-left:var(--global-kb-spacing-sm, 1.5rem);background-color:var(--global-palette7, #EDF2F7);box-shadow:0px 0px 14px 0px rgba(0, 0, 0, 0.2);}.kb-table-of-content-nav.kb-table-of-content-id19563_c031ec-35 .kb-table-of-contents-title-wrap{padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}.kb-table-of-content-nav.kb-table-of-content-id19563_c031ec-35 .kb-table-of-contents-title{font-weight:regular;font-style:normal;}.kb-table-of-content-nav.kb-table-of-content-id19563_c031ec-35 .kb-table-of-content-wrap .kb-table-of-content-list{font-size:var(--global-kb-font-size-sm, 0.9rem);font-weight:regular;font-style:normal;margin-top:var(--global-kb-spacing-sm, 1.5rem);margin-right:0px;margin-bottom:0px;margin-left:0px;}.kb-table-of-content-nav.kb-table-of-content-id19563_c031ec-35 .kb-toggle-icon-style-basiccircle .kb-table-of-contents-icon-trigger:after, .kb-table-of-content-nav.kb-table-of-content-id19563_c031ec-35 .kb-toggle-icon-style-basiccircle .kb-table-of-contents-icon-trigger:before, .kb-table-of-content-nav.kb-table-of-content-id19563_c031ec-35 .kb-toggle-icon-style-arrowcircle .kb-table-of-contents-icon-trigger:after, .kb-table-of-content-nav.kb-table-of-content-id19563_c031ec-35 .kb-toggle-icon-style-arrowcircle .kb-table-of-contents-icon-trigger:before, .kb-table-of-content-nav.kb-table-of-content-id19563_c031ec-35 .kb-toggle-icon-style-xclosecircle .kb-table-of-contents-icon-trigger:after, .kb-table-of-content-nav.kb-table-of-content-id19563_c031ec-35 .kb-toggle-icon-style-xclosecircle .kb-table-of-contents-icon-trigger:before{background-color:var(--global-palette7, #EDF2F7);}<\/style>\n\n<p class='ml_begpost' id='ml_begpost_commands'>If you&#8217;re new to Raspberry Pi or Linux, I\u2019ve got something that can help you right away! <br \/><a rel='noopener' href='https:\/\/raspberrytips.com\/downloads\/?source=begpost&#038;lm=4' target='_blank'>Download my free Linux commands cheat sheet<\/a> \u2013 it\u2019s a quick reference guide with all the essential commands you\u2019ll need to get things done on your Raspberry Pi. <a rel='noopener' href='https:\/\/raspberrytips.com\/downloads\/?source=begpost&#038;lm=4' target='_blank'><b>Click here to get it for free!<\/b><\/a><\/p>\n\n\n<h2 class=\"wp-block-heading\">A Quick Refresher on DNS<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you&#8217;re here, you probably know the basics about DNS services. But it&#8217;s a good idea to review this section to make sure you understand everything during the installation process.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What is DNS?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">DNS stands for Domain Name System. It&#8217;s a main service on the Internet, and its role is to translate domain names into IP addresses.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>On a network, devices only speak with IP addresses, and they need a DNS server to help convert host names to IPs.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, a DNS request could be:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Your computer<\/strong>: What&#8217;s the IP address of raspberrytips.com?<\/li>\n\n\n\n<li><strong>The DNS server<\/strong>: You can use 35.180.0.215<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"200\" src=\"https:\/\/raspberrytips.com\/wp-content\/uploads\/2023\/04\/dns-request-example.jpg\" alt=\"\" class=\"wp-image-16845\" srcset=\"https:\/\/raspberrytips.com\/wp-content\/uploads\/2023\/04\/dns-request-example.jpg 800w, https:\/\/raspberrytips.com\/wp-content\/uploads\/2023\/04\/dns-request-example-300x75.jpg 300w, https:\/\/raspberrytips.com\/wp-content\/uploads\/2023\/04\/dns-request-example-768x192.jpg 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">This kind of&nbsp;request happens all of the time on a network with Internet access.<span id=\"selectionBoundary_1553274703875_7870547540547175\" class=\"rangySelectionBoundary\" style=\"line-height: 0; display: none;\"><\/span><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How Does DNS Work?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Your DNS server is a member of a hierarchy.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>When you send a request there are two outcomes:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The server knows the answer: you get the IP address directly.<\/li>\n\n\n\n<li>The server doesn&#8217;t know the corresponding IP address: the server sends the same request to its own DNS server and sends you back the answer.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">If its own DNS server doesn&#8217;t have the answer, it will ask the upper server, etc.<\/p>\n\n\n<div class=\"wp-block-image wp-image-1811 size-full\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"297\" src=\"https:\/\/raspberrytips.com\/wp-content\/uploads\/2019\/03\/dns-tree.png\" alt=\"dns tree\" class=\"wp-image-1811\" srcset=\"https:\/\/raspberrytips.com\/wp-content\/uploads\/2019\/03\/dns-tree.png 602w, https:\/\/raspberrytips.com\/wp-content\/uploads\/2019\/03\/dns-tree-300x148.png 300w, https:\/\/raspberrytips.com\/wp-content\/uploads\/2019\/03\/dns-tree-100x49.png 100w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><figcaption class=\"wp-element-caption\">A DNS tree schema<\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">In this schema, your Raspberry Pi will be at the bottom of the tree, and each circle is another DNS server. We call the node at the top a root server, and it has the answer for any requests with an existing domain name.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Each request starts at the bottom and climbs the tree every time a DNS server doesn&#8217;t have the answer.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why Would You Want to Install a DNS Server on Your Local Network?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>There are four reasons why&nbsp;you might want to host your own DNS server:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Speed up your Internet browsing<\/strong>: On the tree above, each time the request goes to the next DNS server, there is an additional time to wait. With a DNS server on your network, using a caching system, most of the requests can be answered directly.<\/li>\n\n\n\n<li><strong>Keep your browsing safe<\/strong>: When you use your provider&#8217;s DNS servers, or the Google ones, you are allowing them to know any website you visit on the Internet. By keeping the control on the DNS service, you keep this private (most of the time). Another option is to <a href=\"https:\/\/raspberrytips.com\/install-cloudflared-raspberry-pi\/\" data-type=\"post\" data-id=\"30717\">install Cloudflared on your Raspberry Pi<\/a>, but that&#8217;s not our goal for today.<\/li>\n\n\n\n<li><strong>Stability<\/strong>: Even with using well known DNS servers, you can lose your Internet connection if the servers you&#8217;re using are down or too slow. By having your own DNS servers on your network, you can keep control over this.<\/li>\n\n\n\n<li><strong>Custom records<\/strong>: With a DNS server at home you can create your records in the DNS server. For example, if I want to redirect kodi.me.local to my media center Raspberry Pi it&#8217;s possible.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">There are probably other advantages, and maybe some cons.<br>But if you are a Linux expert, this is easily manageable. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install a DNS Server on Raspberry Pi<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">First, you need to select the software you&#8217;ll use for your DNS service.<br>I already shared my choice with you, but you can choose between:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Bind<\/strong>: the most used DNS service on Linux, but complicated to set up.<\/li>\n\n\n\n<li><b>DNSMasq<\/b>: a lightweight and easy-to-use DNS server.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">So, for this project, you will probably use your Raspberry Pi at home in a small network.<br>DNSMasq is the best option, it will not take many resources and will be easy to configure.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install Raspberry Pi OS<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">I already wrote an entire article about <a data-lasso-id=\"620\" href=\"https:\/\/raspberrytips.com\/install-raspbian-raspberry-pi\/\" target=\"_blank\" rel=\"noopener\">how to install Raspberry Pi OS<\/a>. Click on the link to read the step-by-step tutorial. Raspberry Pi OS Lite will be perfect for this. Enable the network, SSH, and move on to the next steps.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install DNSMasq on Raspberry Pi<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The process to install DNSMasq is straightforward:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Connect to your Raspberry Pi via SSH<\/strong> (or type the following commands directly on it).<\/li>\n\n\n\n<li><strong>Update your system:<\/strong> <br><code>sudo apt update<br>sudo apt upgrade<\/code><\/li>\n\n\n\n<li><strong>Install the DNSMasq package<\/strong>: <br><code>sudo apt install dnsmasq<\/code><br><img loading=\"lazy\" decoding=\"async\" width=\"1127\" height=\"276\" class=\"wp-image-16846\" style=\"\" src=\"https:\/\/raspberrytips.com\/wp-content\/uploads\/2019\/03\/dnsmasq-install.jpg\" alt=\"\" srcset=\"https:\/\/raspberrytips.com\/wp-content\/uploads\/2019\/03\/dnsmasq-install.jpg 1127w, https:\/\/raspberrytips.com\/wp-content\/uploads\/2019\/03\/dnsmasq-install-300x73.jpg 300w, https:\/\/raspberrytips.com\/wp-content\/uploads\/2019\/03\/dnsmasq-install-1024x251.jpg 1024w, https:\/\/raspberrytips.com\/wp-content\/uploads\/2019\/03\/dnsmasq-install-768x188.jpg 768w\" sizes=\"auto, (max-width: 1127px) 100vw, 1127px\" \/><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s it, DNSMasq is now installed.<\/p>\n\n\n\r\n\t\t<!-- wp:paragraph -->\r\n\t<p  id=\"inpost_lm_linux_commands\"><b>Tip: <\/b> Command lines can be a pain to memorize. I put the essential Linux commands on a printable cheat sheet so you don't have to keep googling them.\u00a0You can <a rel=\"noreferrer noopener\" href=\"https:\/\/raspberrytips.com\/downloads\/?source=rb_linux&lm=4\" target=\"_blank\">grab the PDF here<\/a> if you want to save some time.<\/p>\r\n\t<!-- \/wp:paragraph -->\r\n\t\t\n\n\n<h3 class=\"wp-block-heading\">DNSMasq Configuration<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The DNSMasq configuration is found in the <em>\/etc\/dnsmasq.conf<\/em> file on your system. I will show you a basic configuration, but each setting is well commented to allow you to easily find the best one to use.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Open the configuration file with nano:<\/strong> <br><span style=\"color: var(--global-palette4);\"><code>sudo nano \/etc\/dnsmasq.conf<\/code><\/span><\/li>\n\n\n\n<li><strong>Uncomment these three lines<\/strong> (remove the # symbol on each line): <br><span style=\"color: var(--global-palette4);\"><code>domain-needed<\/code><\/span><br><span style=\"color: var(--global-palette4);\"><code>bogus-priv<\/code><\/span><br><span style=\"color: var(--global-palette4);\"><code>expand-hosts<\/code><\/span><br>The two firsts are at the beginning of the file, the expand-hosts is way lower (<a href=\"https:\/\/raspberrytips.com\/nano-commands-shortcuts\/\" data-type=\"post\" data-id=\"2524\">use the Nano shortcuts<\/a> to quickly find them).<br>You can also add them manually if you prefer.<br><img loading=\"lazy\" decoding=\"async\" width=\"1093\" height=\"197\" class=\"wp-image-16847\" style=\"\" src=\"https:\/\/raspberrytips.com\/wp-content\/uploads\/2019\/03\/dnsmasq-conf.jpg\" alt=\"\" srcset=\"https:\/\/raspberrytips.com\/wp-content\/uploads\/2019\/03\/dnsmasq-conf.jpg 1093w, https:\/\/raspberrytips.com\/wp-content\/uploads\/2019\/03\/dnsmasq-conf-300x54.jpg 300w, https:\/\/raspberrytips.com\/wp-content\/uploads\/2019\/03\/dnsmasq-conf-1024x185.jpg 1024w, https:\/\/raspberrytips.com\/wp-content\/uploads\/2019\/03\/dnsmasq-conf-768x138.jpg 768w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><br>The &#8220;domain-needed&#8221; line allows sending DNS requests to the main DNS server only for domain name.<br>&#8220;bogus-priv&#8221; avoids sending DNS requests to the main DNS server if it&#8217;s a local IP.<br>And finally, &#8220;expand-hosts&#8221; will be useful later to add a fake domain name to our local devices.<\/li>\n\n\n\n<li><strong>Then add this line:<\/strong> <br><code><span style=\"color: var(--global-palette4);\">domain=me.local <\/span><br><\/code><span style=\"background-color: rgba(28, 33, 42, 0.2); font-size: revert; color: var(--global-palette4);\">You can set anything you want.<\/span> In my case, me.local will be my local domain name.<br>If I have a host named &#8220;kodi&#8221;, I can now access it with &#8220;kodi.me.local&#8221;.<span id=\"selectionBoundary_1553319358668_2615259028260122\" class=\"rangySelectionBoundary\" style=\"line-height: 0; display: none;\"><\/span><br>We&#8217;ll see that later.<\/li>\n\n\n\n<li><strong>Save and exit (<kbd>CTRL+O, CTRL+X<\/kbd>).<\/strong><\/li>\n\n\n\n<li><strong>Restart DNSMasq to apply changes<\/strong>: <br><span style=\"color: var(--global-palette4);\"><code>sudo systemctl restart dnsmasq<\/code><\/span><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Add a Local Host<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>To create a local host (as kodi.me.local), you need to add it in the hosts file.<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open the hosts file with nano: <br><span style=\"color: var(--global-palette4);\"><code>sudo nano \/etc\/hosts<\/code><\/span><\/li>\n\n\n\n<li>Add a line like this at the end: <br><span style=\"color: var(--global-palette4);\"><code>192.168.1.17    kodi<\/code><\/span><br>This line allows the Raspberry Pi to use &#8220;kodi&#8221; as a name to reach 192.168.1.17.<br>After saving, you can ping kodi from the Raspberry Pi.<br><code>ping kodi<\/code><\/li>\n\n\n\n<li>Save and exit (CTRL+O, CTRL+X).<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The Raspberry Pi can now use &#8220;kodi&#8221; as a host name.<br>And, any computer using the Raspberry Pi as its DNS server can use kodi.me.local to connect to it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Test Lookups<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Before changing the computer configuration, we have to make sure the DNS server is now working correctly. You can use <em>nslookup<\/em> to make DNS requests. It&#8217;s a free tool available on any operating system.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Open a terminal on your computer<\/strong> (command-line interface on Windows).<\/li>\n\n\n\n<li><strong>Start nslookup: <br><\/strong><span style=\"color: var(--global-palette4);\"><code>nslookup<\/code><\/span><\/li>\n\n\n\n<li>By default, nslookup is using your current DNS server.<br><strong>You have&nbsp;to change it like this:<\/strong> <br><span style=\"color: var(--global-palette4);\"><code>server A.B.C.D<\/code><\/span><br><span style=\"background-color: rgba(28, 33, 42, 0.2); font-size: revert; color: var(--global-palette4);\">Replace A.B.C.D by the Raspberry Pi IP address.<\/span> If you don&#8217;t know it, you can read my post about <a rel=\"noopener\" data-lasso-id=\"621\" href=\"https:\/\/raspberrytips.com\/find-current-ip-raspberry-pi\/\" target=\"_blank\">how to get the Raspberry Pi IP address<\/a>.<\/li>\n\n\n\n<li>Then <strong>type any domain name<\/strong> to check that the Raspberry Pi is correctly resolving it:<br><span style=\"color: var(--global-palette4);\"><code>raspberrytips.com<\/code><\/span><\/li>\n\n\n\n<li><strong>It will show you an IP address<\/strong> corresponding to the domain name.<br><img loading=\"lazy\" decoding=\"async\" width=\"563\" height=\"404\" class=\"wp-image-16848\" style=\"\" src=\"https:\/\/raspberrytips.com\/wp-content\/uploads\/2019\/03\/nslookup-test.jpg\" alt=\"\" srcset=\"https:\/\/raspberrytips.com\/wp-content\/uploads\/2019\/03\/nslookup-test.jpg 563w, https:\/\/raspberrytips.com\/wp-content\/uploads\/2019\/03\/nslookup-test-300x215.jpg 300w\" sizes=\"auto, (max-width: 563px) 100vw, 563px\" \/><br>Your DNS server is working.<br>You can also try to resolve the local host (ex: kodi.local.me) to check that it is also working.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Computer Configuration<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The last step is to configure your PC to use the Raspberry Pi as a DNS server.<br>To do this, you have two options.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Manual Configuration<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The first way is to <strong>configure the DNS server manually on your PC.<\/strong> Depending on your operating system, you need to go in your network settings and set the main DNS server with the Raspberry Pi IP address.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, on Windows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Navigate to <strong>Control Panel &gt; Network and Internet &gt; Network and Sharing Center<\/strong><\/li>\n\n\n\n<li>Click on the network interface you are using, and go into its <strong>Properties<\/strong>.<br><img decoding=\"async\" style=\"width: 300px;\" src=\"https:\/\/raspberrytips.com\/wp-content\/uploads\/2019\/03\/windows_network_properties.jpg\" alt=\"\"><\/li>\n\n\n\n<li>Double-click on <strong>Internet Protocol Version 4<\/strong>, and the set the preferred DNS server with the Raspberry Pi IP address.<br><img decoding=\"async\" src=\"https:\/\/raspberrytips.com\/wp-content\/uploads\/2021\/06\/windows-ip-settings.jpg\" alt=\"\" style=\"width: 300px;\"><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">If you&#8217;re on Ubuntu\/Debian instead, you can change it directly in the <em>\/etc\/resolv.conf<\/em> file or in the network manager if you have a graphical desktop.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Related<\/strong>: <a href=\"https:\/\/raspberrytips.com\/dns-settings-ubuntu-server\/\" data-type=\"post\" data-id=\"14469\">How To Change DNS Settings On Ubuntu Servers (Commands)<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">DHCP Configuration<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The second way is to <strong>change the DNS server in your DHCP server.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the DHCP configuration, you can choose the IP range and the DNS server sent to clients.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you have access to this, it&#8217;s probably the best option.<br>It&#8217;ll work directly with all of your devices, including smartphones.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you choose this option, don&#8217;t forget to set manually an external DNS server on your Raspberry Pi.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By the way, you can also <a data-lasso-id=\"622\" href=\"https:\/\/raspberrytips.com\/dhcp-server-on-raspberry-pi\/\" data-type=\"post\" data-id=\"8294\" target=\"_blank\" rel=\"noopener\">use your Raspberry Pi as a DHCP server<\/a>, it will be simpler.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Video<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you need a more step-by-step demonstration, I have recorded a video on the topic. You can watch it here if you want:<\/p>\n\n\n\n<figure class=\"wp-block-embed aligncenter is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"container-lazyload preview-lazyload container-youtube js-lazyload--not-loaded\"><a href=\"https:\/\/youtu.be\/cxaAiBVGf7s\" class=\"lazy-load-youtube preview-lazyload preview-youtube\" data-video-title=\"How to use your Raspberry Pi as a DNS Server (DNSMasq) and speed up your Internet\" title=\"Play video &quot;How to use your Raspberry Pi as a DNS Server (DNSMasq) and speed up your Internet&quot;\">https:\/\/youtu.be\/cxaAiBVGf7s<\/a><noscript>Video can&#8217;t be loaded because JavaScript is disabled: <a href=\"https:\/\/youtu.be\/cxaAiBVGf7s\" title=\"How to use your Raspberry Pi as a DNS Server (DNSMasq) and speed up your Internet\">How to use your Raspberry Pi as a DNS Server (DNSMasq) and speed up your Internet (https:\/\/youtu.be\/cxaAiBVGf7s)<\/a><\/noscript><\/div>\n<\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Subscribe to the RaspberryTips YouTube channel to receive new videos in your feed:<\/p>\n\n\n<p><script src=\"https:\/\/apis.google.com\/js\/platform.js\"><\/script><\/p>\n<div class=\"g-ytsubscribe\" data-channelid=\"UCy9KSeom3ngT7_FYKnNIShg\" data-layout=\"full\" data-count=\"hidden\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s it, you now know how to install a DNS server on a Raspberry Pi, and how to configure it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The goal of this tutorial was to show you the basics about DNS services.<br>If you want to go further, I recommend you to <a rel=\"noopener\" href=\"http:\/\/www.thekelleys.org.uk\/dnsmasq\/docs\/dnsmasq-man.html\" target=\"_blank\" data-lasso-id=\"623\">read the official website<\/a> for more options.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I didn&#8217;t write about the DHCP feature here as it was not the goal of this post, but you can use DNSMasq as a DHCP server too (<a href=\"https:\/\/raspberrytips.com\/dhcp-server-on-raspberry-pi\/\" data-type=\"post\" data-id=\"8294\">I have a complete guide here<\/a>).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To use your Raspberry Pi as an all-in-one network server, you can also check my post on <a data-lasso-id=\"624\" href=\"https:\/\/raspberrytips.com\/raspberry-pi-firewall\/\" target=\"_blank\" rel=\"noopener\">how to use it as Wireless Hotspot, router and firewall<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The combination of these two tutorials should be perfect :).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related Questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">How do I enable request caching on DNSMasq?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">DNSMasq uses caching by default. If needed, you can increase the cache-size value in the \/etc\/dnsmasq.conf file. For a small network, a value near 3000 should be fine.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How do I measure my real Internet speed up with DNSMasq?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The best option is to use the dig command from your computer.&nbsp; With a dig query (dig google.com) you get the corresponding IP, but also the query time. By using an Internet DNS server, query time will be at least 30ms each time. With a local server, the first one will be 30ms, and all the following under 5ms.<\/p>\n\n\n<section id=\"end-block-pi\">\r\n<div class=\"rt-community-card \">\r\n\t<div class=\"rt-community-card__inner\">\r\n\r\n\t\t<div class=\"rt-community-card__main\">\r\n\t\t\t<h3 class=\"rt-community-card__headline\">\r\n\t\t\t\tNot getting the same result?\t\t\t<\/h3>\r\n\r\n\t\t\t<p class=\"rt-community-card__description\">\r\n\t\t\t\tEven when you follow every step, small differences in OS version, hardware or config can change the outcome. Instead of wasting time guessing, get help from people who have already fixed the same kind of issue.\t\t\t<\/p>\r\n\r\n\t\t\t<div class=\"rt-community-card__actions\">\r\n\t\t\t\t<a class=\"rt-community-card__button\" href=\"https:\/\/raspberrytips.com\/school\/community\/?coupon=EBCTY\">\r\n\t\t\t\t\t<span>Ask your question now<\/span>\r\n\t\t\t\t\t<span class=\"rt-community-card__button-arrow\">\u2192<\/span>\r\n\t\t\t\t<\/a>\r\n\r\n\t\t\t\t\t\t\t\t\t<div class=\"rt-community-card__small\">\r\n\t\t\t\t\t\t<span class=\"rt-community-card__small-lock\">\ud83d\udd12<\/span>\r\n\t\t\t\t\t\tNo risk. Cancel anytime.\t\t\t\t\t<\/div>\r\n\t\t\t\t\t\t\t<\/div>\r\n\t\t<\/div>\r\n\r\n\t\t\t\t\t<div class=\"rt-community-card__side\">\r\n\t\t\t\t<ul class=\"rt-community-card__benefits\">\r\n\t\t\t\t\t\t\t\t\t\t\t<li>Get help on your exact issue<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t<li>Access step-by-step videos for tricky setups<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t<li>Browse the website without ads<\/li>\r\n\t\t\t\t\t\t\t\t\t<\/ul>\r\n\t\t\t<\/div>\r\n\t\t\r\n\t<\/div>\r\n<\/div>\r\n<\/section>\r\n\r\n<style>\r\n.rt-community-card {\r\n\t--rt-bg: #f7f7f9;\r\n\t--rt-border: #e4e4e8;\r\n\t--rt-text: #15171b;\r\n\t--rt-muted: #5b6270;\r\n\t--rt-accent: #C61E4A;\r\n\t--rt-accent-hover: #aa183f;\r\n\t--rt-shadow: 0 12px 30px rgba(0, 0, 0, 0.06);\r\n\r\n\tmargin: 36px 0;\r\n\tcolor: var(--rt-text);\r\n\tfont-family: inherit;\r\n}\r\n\r\n.rt-community-card__inner {\r\n\tdisplay: grid;\r\n\tgrid-template-columns: minmax(0, 1.55fr) minmax(260px, 0.95fr);\r\n\tgap: 34px;\r\n\talign-items: start;\r\n\tbackground: var(--rt-bg);\r\n\tborder: 1px solid var(--rt-border);\r\n\tborder-radius: 22px;\r\n\tpadding: 34px 36px;\r\n\tbox-shadow: var(--rt-shadow);\r\n}\r\n\r\n.rt-community-card__main {\r\n\tmin-width: 0;\r\n}\r\n\r\n.rt-community-card__side {\r\n\tborder-left: 1px solid #e1e1e6;\r\n\tpadding-left: 28px;\r\n}\r\n\r\n.rt-community-card__benefits {\r\n\tmargin: 6px 0 0;\r\n\tpadding: 0;\r\n\tlist-style: none;\r\n\tdisplay: grid;\r\n\tgap: 18px;\r\n}\r\n\r\n.rt-community-card__benefits li {\r\n\tposition: relative;\r\n\tpadding-left: 18px;\r\n\tfont-size: 18px;\r\n\tline-height: 1.55;\r\n\tcolor: var(--rt-text);\r\n}\r\n\r\n.rt-community-card__benefits li::before {\r\n\tcontent: \"\";\r\n\tposition: absolute;\r\n\tleft: 0;\r\n\ttop: 0.72em;\r\n\twidth: 7px;\r\n\theight: 7px;\r\n\tborder-radius: 999px;\r\n\tbackground: var(--rt-accent);\r\n\ttransform: translateY(-50%);\r\n}\r\n\r\n.rt-community-card__actions {\r\n\tdisplay: flex;\r\n\tflex-direction: column;\r\n\talign-items: flex-start;\r\n\tgap: 10px;\r\n\tmargin-top: 30px;\r\n}\r\n\r\n.rt-community-card__button {\r\n\tdisplay: inline-flex;\r\n\talign-items: center;\r\n\tjustify-content: center;\r\n\tgap: 10px;\r\n\tmin-height: 60px;\r\n\tpadding: 0 28px;\r\n\tborder-radius: 14px;\r\n\tbackground: var(--rt-accent);\r\n\tcolor: #fff !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 21px;\r\n\tfont-weight: 700;\r\n\tline-height: 1;\r\n\tbox-shadow: 0 12px 22px rgba(198, 30, 74, 0.22);\r\n\ttransition: background .2s ease, transform .2s ease, box-shadow .2s ease;\r\n}\r\n\r\n.rt-community-card__button:hover {\r\n\tbackground: var(--rt-accent-hover);\r\n\tcolor: #fff !important;\r\n\ttransform: translateY(-1px);\r\n\tbox-shadow: 0 14px 26px rgba(198, 30, 74, 0.28);\r\n}\r\n\r\n.rt-community-card__button-arrow {\r\n\tfont-size: 20px;\r\n\tline-height: 1;\r\n}\r\n\r\n.rt-community-card__small {\r\n\tfont-size: 15px;\r\n\tline-height: 1.5;\r\n\tcolor: #6a717d;\r\n\tpadding-left: 2px;\r\n}\r\n\r\n.rt-community-card__small-lock {\r\n\tmargin-right: 6px;\r\n\tfont-size: 14px;\r\n\tvertical-align: baseline;\r\n}\r\n\r\n\/* Tablet *\/\r\n@media (max-width: 900px) {\r\n\t.rt-community-card {\r\n\t\tmargin: 28px 0;\r\n\t}\r\n\r\n\t.rt-community-card__inner {\r\n\t\tgrid-template-columns: 1fr;\r\n\t\tgap: 24px;\r\n\t\tpadding: 28px 24px;\r\n\t}\r\n\r\n\t.rt-community-card__side {\r\n\t\tborder-left: 0;\r\n\t\tborder-top: 1px solid #e1e1e6;\r\n\t\tpadding-left: 0;\r\n\t\tpadding-top: 22px;\r\n\t}\r\n\r\n\t.rt-community-card__benefits {\r\n\t\tgrid-template-columns: 1fr;\r\n\t\tgap: 12px;\r\n\t}\r\n}\r\n\r\n\/* Mobile *\/\r\n@media (max-width: 640px) {\r\n\t.rt-community-card__inner {\r\n\t\tpadding: 22px 18px;\r\n\t\tborder-radius: 18px;\r\n\t\tgap: 20px;\r\n\t}\r\n\t\r\n\t.rt-community-card__side {\r\n\t\tpadding-top: 18px;\r\n\t}\r\n\r\n\t.rt-community-card__benefits li {\r\n\t\tfont-size: 16px;\r\n\t}\r\n\r\n\t.rt-community-card__actions {\r\n\t\tmargin-top: 24px;\r\n\t\talign-items: stretch;\r\n\t}\r\n\r\n\t.rt-community-card__button {\r\n\t\twidth: 100%;\r\n\t\tmin-height: 56px;\r\n\t\tfont-size: 18px;\r\n\t\tpadding: 0 20px;\r\n\t}\r\n\r\n\t.rt-community-card__small {\r\n\t\ttext-align: center;\r\n\t\tpadding-left: 0;\r\n\t}\r\n}\r\n<\/style>\r\n\t\r\n","protected":false},"excerpt":{"rendered":"<p>I didn\u2019t expect much the first time I turned my Raspberry Pi into a DNS server, but it ended up being one of the simplest upgrades I\u2019ve made to my network. If you\u2019re curious about speeding up your browsing and learning how DNS really works, you\u2019re going to like this. DNSMasq is a service that&#8230;<\/p>\n","protected":false},"author":1,"featured_media":49220,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[2],"tags":[],"class_list":["post-1807","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to-tutorials"],"taxonomy_info":{"category":[{"value":2,"label":"How-To Tutorials"}]},"featured_image_src_large":["https:\/\/raspberrytips.com\/wp-content\/uploads\/2019\/03\/dns-server-raspberry-pi-1024x683.jpg",1024,683,true],"author_info":{"display_name":"Patrick Fromaget","author_link":"https:\/\/raspberrytips.com\/author\/admin\/"},"comment_info":13,"category_info":[{"term_id":2,"name":"How-To Tutorials","slug":"how-to-tutorials","term_group":0,"term_taxonomy_id":2,"taxonomy":"category","description":"","parent":0,"count":228,"filter":"raw","cat_ID":2,"category_count":228,"category_description":"","cat_name":"How-To Tutorials","category_nicename":"how-to-tutorials","category_parent":0}],"tag_info":false,"_links":{"self":[{"href":"https:\/\/raspberrytips.com\/wp-json\/wp\/v2\/posts\/1807","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/raspberrytips.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/raspberrytips.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/raspberrytips.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/raspberrytips.com\/wp-json\/wp\/v2\/comments?post=1807"}],"version-history":[{"count":28,"href":"https:\/\/raspberrytips.com\/wp-json\/wp\/v2\/posts\/1807\/revisions"}],"predecessor-version":[{"id":49222,"href":"https:\/\/raspberrytips.com\/wp-json\/wp\/v2\/posts\/1807\/revisions\/49222"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/raspberrytips.com\/wp-json\/wp\/v2\/media\/49220"}],"wp:attachment":[{"href":"https:\/\/raspberrytips.com\/wp-json\/wp\/v2\/media?parent=1807"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/raspberrytips.com\/wp-json\/wp\/v2\/categories?post=1807"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/raspberrytips.com\/wp-json\/wp\/v2\/tags?post=1807"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}