{"id":6671,"date":"2022-09-29T21:25:45","date_gmt":"2022-09-29T21:25:45","guid":{"rendered":"https:\/\/www.geekdecoder.com\/?p=6671"},"modified":"2022-09-29T21:25:45","modified_gmt":"2022-09-29T21:25:45","slug":"basic-dns-setup-with-dnsmasq","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2022\/09\/29\/basic-dns-setup-with-dnsmasq\/","title":{"rendered":"Basic DNS Setup with DNSMASQ"},"content":{"rendered":"<p>Dnsmasq is a lightweight, easy to configure, DNS forwarder and DHCP server. It is designed to provide DNS and optionally, DHCP, to a small network. It can serve the names of local machines which are not in the global DNS.<\/p>\n<p>Source: https:\/\/wiki.debian.org\/dnsmasq<\/p>\n<p>Basic DNS Setup<br \/>\nFirst things first, let&#8217;s install the package:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\napt-get update\napt-get install dnsmasq\n<\/pre>\n<p>If your goal was to set up a simple DNS server, you just succeeded. To test it, use your favorite DNS lookup tool pointed at localhost:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndig debian.org @localhost\n; &lt;&lt;&gt;&gt; DiG 9.16.33-Debian &lt;&lt;&gt;&gt; debian.org @localhost\n;; global options: +cmd\n;; Got answer:\n;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 23056\n;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1\n\n;; OPT PSEUDOSECTION:\n; EDNS: version: 0, flags:; udp: 4096\n;; QUESTION SECTION:\n;debian.org.                    IN      A\n\n;; ANSWER SECTION:\ndebian.org.             300     IN      A       149.20.4.15\ndebian.org.             300     IN      A       130.89.148.77\ndebian.org.             300     IN      A       128.31.0.62\n\n;; Query time: 44 msec\n;; SERVER: ::1#53(::1)\n;; WHEN: Thu Sep 29 16:26:24 CDT 2022\n;; MSG SIZE  rcvd: 87\n\n<\/pre>\n<p>or<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nnslookup debian.org localhost\nServer:         localhost\nAddress:        ::1#53\n\nNon-authoritative answer:\nName:   debian.org\nAddress: 128.31.0.62\nName:   debian.org\nAddress: 130.89.148.77\nName:   debian.org\nAddress: 149.20.4.15\nName:   debian.org\nAddress: 2001:67c:2564:a119::77\nName:   debian.org\nAddress: 2603:400a:ffff:bb8::801f:3e\nName:   debian.org\nAddress: 2001:4f8:1:c::15\n<\/pre>\n<p>By default, DNS is configured to forward all requests to your system&#8217;s default DNS settings. In case you didn&#8217;t know, these are stored in the \/etc\/resolv.conf<\/p>\n<p>To add names, simply add them to your \/etc\/hosts file.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nnano \/etc\/hosts\n192.168.0.155   ipgw.io \n<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndig ipgw.io @localhost\n\n; &lt;&lt;&gt;&gt; DiG 9.16.33-Debian &lt;&lt;&gt;&gt; ipgw.io @localhost\n;; global options: +cmd\n;; Got answer:\n;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 53022\n;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1\n\n;; OPT PSEUDOSECTION:\n; EDNS: version: 0, flags:; udp: 4096\n;; QUESTION SECTION:\n;ipgw.io.                       IN      A\n\n;; ANSWER SECTION:\nipgw.io.                0       IN      A       192.168.0.155\n\n;; Query time: 0 msec\n;; SERVER: ::1#53(::1)\n;; WHEN: Thu Sep 29 16:31:02 CDT 2022\n;; MSG SIZE  rcvd: 52\n\n<\/pre>\n<p>Choosing Your Interfaces<br \/>\nOne you will probably want to do is tell dnsmasq which ethernet interface it can and cannot listen on, as we really don&#8217;t want it listening on the internet. Around line 69 of the \/etc\/dnsmasq.conf file, you will see:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n#interface=\n<\/pre>\n<p>By default, DHCP is turned off. <\/p>\n<p>Now change your dns on the IPv4 to your dnsmasq address server and your DNS server like Cloudflare.<\/p>\n<p><a href=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2022\/09\/Screenshot-2022-09-29-164445.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2022\/09\/Screenshot-2022-09-29-164445-1024x586.png\" alt=\"\" width=\"640\" height=\"366\" class=\"alignnone size-large wp-image-6679\" srcset=\"https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2022\/09\/Screenshot-2022-09-29-164445-1024x586.png 1024w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2022\/09\/Screenshot-2022-09-29-164445-300x172.png 300w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2022\/09\/Screenshot-2022-09-29-164445-768x440.png 768w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2022\/09\/Screenshot-2022-09-29-164445.png 1128w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Dnsmasq is a lightweight, easy to configure, DNS forwarder and DHCP server. It is designed to provide DNS and optionally, DHCP, to a small network. It can serve the names of local machines which are not in the global DNS. Source: https:\/\/wiki.debian.org\/dnsmasq Basic DNS Setup First things first, let&#8217;s install the package: apt-get update apt-get &#8230; <a title=\"Basic DNS Setup with DNSMASQ\" class=\"read-more\" href=\"https:\/\/www.qbytes.cloud\/index.php\/2022\/09\/29\/basic-dns-setup-with-dnsmasq\/\" aria-label=\"Read more about Basic DNS Setup with DNSMASQ\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[],"class_list":["post-6671","post","type-post","status-publish","format-standard","hentry","category-dns"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/6671","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=6671"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/6671\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=6671"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=6671"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=6671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}