diff options
| -rw-r--r-- | content/coturn.md | 7 | ||||
| -rw-r--r-- | content/dnsmasq.md | 135 | ||||
| -rw-r--r-- | content/ejabberd.md | 7 | ||||
| -rw-r--r-- | static/pix/dnsmasq.svg | 14 |
4 files changed, 157 insertions, 6 deletions
diff --git a/content/coturn.md b/content/coturn.md index 7c9687c..51a1f2c 100644 --- a/content/coturn.md +++ b/content/coturn.md @@ -106,6 +106,7 @@ Congratulations! You\'ve successfully setup a Coturn server! ------------------------------------------------------------------------ -*Written by [Denshi.](https://denshi.org) Donate Monero -[here](https://denshi.org/donate.html) -[\[QR\]](https://denshi.org/images/monero.jpg)* +*Written by [Denshi.](https://denshi.org) + +Donate Monero at 48dnPpGgo8WernVJp5VhvhaX3u9e46NujdYA44u8zuMdETNC5jXiA9S7JoYMM6qRt1ZcKpt1J3RZ3JPuMyXetmbHH7Mnc9C +[\[QR\]](https://denshi.org/images/xmr.png)* diff --git a/content/dnsmasq.md b/content/dnsmasq.md new file mode 100644 index 0000000..6259910 --- /dev/null +++ b/content/dnsmasq.md @@ -0,0 +1,135 @@ +--- +title: "Dnsmasq" +icon: 'dnsmasq.svg' +tags: ['service'] +short_desc: "Host your own DNS server to block ads and social media." +--- + +[Dnsmasq](https://dnsmasq.org) is a libre DNS and DHCP system that allows anyone to run a DNS server to resolve domains. +Normally to block domains and ads, users on most operating systems can edit their **`/etc/hosts` file** or use one of the many existing ad-blocking hosts collections available online. +However, if you're trying to block ads **over your entire home network** and do not have access to your router's hosts file, +then setting up your own DNS server can be very advantageous. + +This also comes with the benefit of increased flexibility regarding name resolution; +for example, with Dnsmasq, you can employ the usage of **wildcard domains** to block massive ranges of ads, trackers and entire social media networks. + +## Before we begin... +while Dnsmasq is very versatile software that can be used for a variety of networking and DNS applications, +this guide assumes you only want to setup Dnsmasq to **block domains from resolving** (ie. ads and social media sites). +It is possible to get **custom domain resolution** and **internal network services** running using Dnsmasq, +but this is beyond the scope of this article. + +## Installation +Dnsmasq is available in the Debian repositories: +``` +apt install dnsmasq +``` + +## Configuration +### Basic configuration +By default, Dnsmasq will start a DNS server listening on `localhost:53`. +You can even test this if you have the `bind9` package installed: + +```sh +dig @localhost example.org +``` + +This command should return the A DNS records for `example.org`. + +We can configure Dnsmasq to listen on the public internet by editing its config file, `/etc/dnsmasq.conf`. +In this file, you'll find this line, commented out: + +```sh +#interface= +``` +We need to specify the **interface we wish to listen on** to provide the DNS service. +In most cases (such as when using a Debian VPS) this will simply be `eth0`. +However, please run `ip a` to determine which interface is correct for your system, if you're unsure. + +```sh +interface={{<hl>}}eth0{{</hl>}} +``` + +It's also **highly recommended** to uncomment this following line, +just to prevent Dnsmasq from forwarding requests to local names. +``` +domain-needed +``` + +Now all we have to do is restart Dnsmasq's systemd service: + +```sh +systemctl restart dnsmasq +``` + +And, on our **local machine,** we can try using the `bind9` utilities to test our DNS server: +```sh +dig @{{<hl>}}your_servers_public_ip{{</hl>}} example.org +``` + +This should return the correct A DNS records for `example.org`, like when testing using `localhost`. + +### Changing Authoritative DNS Providers +By default, Dnsmasq will use the DNS servers provided in `/etc/resolv.conf`. +You can change this file directly, altering DNS resolution for your entire system: + +```sh +# Quad9 DNS Server +nameserver {{<hl>}}9.9.9.9{{</hl>}} +nameserver {{<hl>}}149.112.112.112{{</hl>}} +``` + +## Blocking DNS Requests + +### Using a Hostsfile +As mentioned previously, one of Dnsmasq's advantages is that it can read `/etc/hosts` and other host resolution files. +This makes it 100% compatible with existing ad-blocking hosts files. + +```sh +0.0.0.0 www.youtube.com +0.0.0.0 www.reddit.com +``` +This hosts file blocks `www.youtube.com` and `www.reddit.com`. + +To read another hosts file, in addition to `/etc/hosts`, you can use the following in `/etc/dnsmasq`: +```sh +addn-hosts=/etc/hosts.2 +``` + +The only complication is that **every time you update the hosts file, Dnsmasq must be restarted:** + +```sh +systemctl restart dnsmasq +``` + +### Using Dnsmasq's Configuration +For more advanced forms of DNS blocking, such as **domain wildcards,** you can edit `/etc/dnsmasq.conf` directly: + +```sh +address=/{{<hl>}}netflix.com{{</hl>}}/0.0.0.0 +``` +This configuration will block all requests to `netflix.com` and its subdomains. This way you **don't need a massive hosts file** containing every single possible subdomain. All you need to know is the root domain. + +And as usual, remember to restart the Dnsmasq systemd service every time the configuration is altered. +``` +systemctl restart dnsmasq +``` + +## Using Dnsmasq +If you intend to use your new DNS server on your home network, +this is as easy as setting your primary DNS resolver in your router's settings to your **DNS server's public IP address.** + +For example, on a local Linux machine, you could edit `/etc/resolv.conf`: +```sh +nameserver {{<hl>}}your_servers_public_ip{{</hl>}} +``` + +Generally this should be an intuitive process on most router interfaces, +and most OS' will let you edit the DNS in their respective network settings. + +------------------------------------------------------------------------ + +*Written by [Denshi.](https://denshi.org) + +Donate Monero at 48dnPpGgo8WernVJp5VhvhaX3u9e46NujdYA44u8zuMdETNC5jXiA9S7JoYMM6qRt1ZcKpt1J3RZ3JPuMyXetmbHH7Mnc9C +[\[QR\]](https://denshi.org/images/xmr.png)* diff --git a/content/ejabberd.md b/content/ejabberd.md index 5a7b716..76e6678 100644 --- a/content/ejabberd.md +++ b/content/ejabberd.md @@ -259,6 +259,7 @@ And with that, you\'ve successfully setup your ejabberd XMPP server! ------------------------------------------------------------------------ -*Written by [Denshi.](https://denshi.org) Donate Monero -[here](https://denshi.org/donate.html) -[\[QR\]](https://denshi.org/images/monero.jpg)* +*Written by [Denshi.](https://denshi.org) + +Donate Monero at 48dnPpGgo8WernVJp5VhvhaX3u9e46NujdYA44u8zuMdETNC5jXiA9S7JoYMM6qRt1ZcKpt1J3RZ3JPuMyXetmbHH7Mnc9C +[\[QR\]](https://denshi.org/images/xmr.png)* diff --git a/static/pix/dnsmasq.svg b/static/pix/dnsmasq.svg new file mode 100644 index 0000000..7c1732e --- /dev/null +++ b/static/pix/dnsmasq.svg @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?> +<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.1" x="0px" y="0px" width="83.756851" height="46.067505" viewBox="0 0 83.756851 46.067505" enable-background="new 0 0 72.833 46.667" xml:space="preserve" id="svg2" inkscape:version="0.47 r22583" sodipodi:docname="dnsmasq_icon.2010_10_21_08_54_27.0.svg"><metadata id="metadata27"><rdf:RDF><cc:Work rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/><dc:title/></cc:Work></rdf:RDF></metadata><defs id="defs25"><inkscape:perspective sodipodi:type="inkscape:persp3d" inkscape:vp_x="0 : 23.3335 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_z="72.833 : 23.3335 : 1" inkscape:persp3d-origin="36.4165 : 15.555667 : 1" id="perspective4857"/> + <filter id="filter3802" inkscape:label="filter1" color-interpolation-filters="sRGB"/><linearGradient inkscape:collect="always" xlink:href="#SVGID_3_" id="linearGradient4929" gradientUnits="userSpaceOnUse" x1="30.564501" y1="-8.8144999" x2="32.937" y2="32.715599"/> + <linearGradient inkscape:collect="always" xlink:href="#SVGID_3_" id="linearGradient5798" gradientUnits="userSpaceOnUse" x1="30.564501" y1="-8.8144999" x2="32.937" y2="32.715599"/><linearGradient inkscape:collect="always" xlink:href="#SVGID_3_" id="linearGradient5812" gradientUnits="userSpaceOnUse" x1="30.564501" y1="-8.8144999" x2="32.937" y2="32.715599"/><filter id="filter6262" inkscape:label="Drop shadow" width="1.5" height="1.5" x="-0.25" y="-0.25" color-interpolation-filters="sRGB"><feGaussianBlur id="feGaussianBlur6264" in="SourceAlpha" stdDeviation="2.500000" result="blur"/><feColorMatrix id="feColorMatrix6266" result="bluralpha" type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0.500000 0 "/><feOffset id="feOffset6268" in="bluralpha" dx="2.700000" dy="2.600000" result="offsetBlur"/><feMerge id="feMerge6270"><feMergeNode id="feMergeNode6272" in="offsetBlur"/><feMergeNode id="feMergeNode6274" in="SourceGraphic"/></feMerge></filter></defs><sodipodi:namedview pagecolor="#ffffff" bordercolor="#666666" borderopacity="1" objecttolerance="10" gridtolerance="10" guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" inkscape:window-width="1568" inkscape:window-height="1076" id="namedview23" showgrid="false" inkscape:zoom="1" inkscape:cx="31.966768" inkscape:cy="23.211869" inkscape:window-x="567" inkscape:window-y="328" inkscape:window-maximized="0" inkscape:current-layer="layer1" inkscape:showpageshadow="false" showborder="false"/> +<g inkscape:groupmode="layer" id="layer1" inkscape:label="dnsmasq" style="display:inline" transform="translate(5.2838057,-0.47786591)"><g id="g3790" transform="translate(91.821581,0.57952319)" style="filter:url(#filter6262)"><g transform="translate(-91.018462,1.0687099)" id="g9"> + <path style="fill:#6700ad" inkscape:connector-curvature="0" id="path11" d="M 54.997,12.151 C 50.083,9.132 43.29,7.266 35.791,7.266 c -7.5,0 -14.29,1.866 -19.204,4.885 -4.915,3.016 -7.956,7.184 -7.956,11.789 0,4.604 3.041,8.772 7.956,11.788 4.914,3.02 11.704,-4.271 19.204,-4.271 7.499,0 14.292,7.291 19.206,4.271 4.914,-3.016 7.955,-7.185 7.955,-11.788 0,-4.606 -3.041,-8.773 -7.955,-11.789 z M 24.996,24.318 c -2.698,0 -4.885,-0.922 -4.885,-2.061 0,-1.14 2.187,-2.063 4.885,-2.063 2.697,0 4.885,0.924 4.885,2.063 0,1.139 -2.188,2.061 -4.885,2.061 z m 21.501,0.191 c -2.686,0 -4.861,-0.856 -4.861,-1.912 0,-1.054 2.176,-1.911 4.861,-1.911 2.685,0 4.863,0.857 4.863,1.911 0,1.056 -2.178,1.912 -4.863,1.912 z"/> + <path style="fill:none;stroke:#ffb616;stroke-width:1.51689994" inkscape:connector-curvature="0" id="path13" d="M 54.997,12.151 C 50.083,9.132 43.29,7.266 35.791,7.266 c -7.5,0 -14.29,1.866 -19.204,4.885 -4.915,3.016 -7.956,7.184 -7.956,11.789 0,4.604 3.041,8.772 7.956,11.788 4.914,3.02 11.704,-4.271 19.204,-4.271 7.499,0 14.292,7.291 19.206,4.271 4.914,-3.016 7.955,-7.185 7.955,-11.788 0,-4.606 -3.041,-8.773 -7.955,-11.789 z M 24.996,24.318 c -2.698,0 -4.885,-0.922 -4.885,-2.061 0,-1.14 2.187,-2.063 4.885,-2.063 2.697,0 4.885,0.924 4.885,2.063 0,1.139 -2.188,2.061 -4.885,2.061 z m 21.501,0.191 c -2.686,0 -4.861,-0.856 -4.861,-1.912 0,-1.054 2.176,-1.911 4.861,-1.911 2.685,0 4.863,0.857 4.863,1.911 0,1.056 -2.178,1.912 -4.863,1.912 z"/> + </g><g transform="translate(-91.018462,1.0687099)" id="Layer_2"> + <linearGradient y2="32.715599" x2="32.937" y1="-8.8144999" x1="30.564501" gradientUnits="userSpaceOnUse" id="SVGID_3_"> + <stop id="stop17" style="stop-color:#FFFFFF;stop-opacity:0.73" offset="0"/> + <stop id="stop19" style="stop-color:#FFFFFF;stop-opacity:0" offset="1"/> + </linearGradient> + <path inkscape:connector-curvature="0" style="fill:url(#linearGradient5812)" id="path21" d="m 54.1,15.361 c -0.924,1.078 -2.782,1.265 -3.857,1.06 C 38,14.083 22.75,12.75 16.027,23.031 14.858,24.819 11.992,25.39 10.293,23.887 8.631,22.417 13.105,15.804 17.646,13.033 22.194,10.252 28.474,8.53 35.41,8.53 c 6.936,0 13.215,1.722 17.756,4.502 0.731,0.442 1.627,1.52 0.934,2.329 z"/> +</g></g></g></svg>
\ No newline at end of file |
