Private DNS Server on RPI3+ and pushing it to the limit with Performance testing using Jmeter
Tags: dns, bind9, raspberrypi, jmeter
Published: 2023-02-11 06:34:05

---
title: Private DNS Server on RPI3+ and pushing it to the limit with Performance testing using Jmeter
published: true
date: 2019-06-15 15:35:03 UTC
tags: dns,bind9,raspberrypi,jmeter
canonical_url: https://kazimurtaza.medium.com/private-dns-server-on-rpi3-and-pushing-it-to-the-limit-with-performance-testing-using-jmeter-b23c6fc42a96
---

I plan on configuring DNS server on my rpi3+, why you ask, well my reason for the time being are simple, just because I can, in reality, I have too many services running at home, and remembering IP’s for all them has become somewhat hectic, and does not seem very nice.

This idea led me to an interesting discussion already going on the internet, why is everyone opting for the same, some for security, or privacy or caching. so I wanted to discover what was all the fuss about and actually prove to myself that RPI3, packs a punch.

### Key concepts to ensure best practice([link](https://security.stackexchange.com/questions/39504/pros-cons-of-using-a-private-dns-vs-a-public-dns))

- DNS only answers to IP(s) on the internal domain,
- Configure this DNS server to only use root hints and not forwarders (this can largely mitigate MITM attacks).
- Have a local caching nameserver for faster query time and to prevent NXDOMAIN hijacking,
- Recursion is allowed on a private DNS server as long as you make sure you have taken the first point into account.

### Some advantages which are the reason why I am opting to have DNS Server,

- DNS server can resolve domains, within the network. You could, for instance, resolve “hello.world.com” to your torrent server.
- _DNS can be used as a poor man’s blacklist_. you can block all unwanted domains, redirecting the request to a more suitable website.
- Users in my network, are using a trusted DNS server and not some hijacked one.
- we can block most of the ads, by blocking their IP(s).

### why should we just keep our amateurly-configured DNS server private?

DNS protocol attacks are pretty common amongst hackers, some basic forms of attacks are; a detailed description of them can be found [here](https://www.sans.org/reading-room/whitepapers/dns/security-issues-dns-1069).

- DNS spoofing
- DNS ID hacking
- DNS cache poisoning

### Why choose raspberry pi?

With evermoving innovation in arm based platforms, I have always been impressed by what these tiny machines with tiny footprint can do. let us prove if they provide value for money.

**Prerequisite for implementing DNS Server on Raspberry PI**

- Raspberry PI,
- Raspian Lite Image installed,
- Internet connection, Internal static IP,
- SSH enabled.

_Comparison of DNS Server can be found_ [_here_](https://en.wikipedia.org/wiki/Comparison_of_DNS_server_software)_, I choose Bind, because of how widely accepted it is, and also it is open sourced, which mean it has good community support._

Following the tutorial [here](https://www.ionos.com/digitalguide/server/configuration/how-to-make-your-raspberry-pi-into-a-dns-server/), I was able to successfully install Bind9 on the server but to be able to achieve my goal listed above, I had to modify the conf files present in the link.

```
**cat /etc/bind/db.subdomain.example.com**

$TTL 14400
@ IN SOA ns1.subdomain.example.com. hostmaster.subdomain.example.com. (

201006601 ; Serial
7200 ; Refresh
120 ; Retry
2419200 ; Expire
604800) ; Default TTL;

subdomain.example.com. IN NS ns1.subdomain.example.com.
subdomain.example.com. IN NS ns2.subdomain.example.com.
subdomain.example.com. IN MX 10 mail.subdomain.example.com.

ns1 IN A 192.168.100.100
ns2 IN A 192.168.100.102

www IN CNAME subdomain.example.com.

mail IN A 192.168.100.103

subdomain.example.com. IN A 192.168.100.1
raspberrypi3 IN A 192.168.100.100
raspberrypi2 IN A 192.168.100.101
router IN A 192.168.100.200
```

Test your DNS server works perfectly before you go update every pc, for that I found [this](https://domoticproject.com/configuring-dns-server-raspberry-pi/) article to be much help.

```
sudo named-checkconf
```

_this command when executing on the DNS server would return an error if conf files are not properly configured._

next as the article suggests keep an eye on the logs, and yes use the **dig** command to ensure domain, is resolving correctly.

Now you can go ahead and update the internal network, or servers/pcs to your new DNS server.

Now comes the part we have all been waiting for **Performance Testing DNS Server on RPI3+** , pushing it to the limit with concurrent load, for that, I follow this article [here](https://jmeter-plugins.org/wiki/dns_test_using_jmeter/), though I made some changes not sure if they are correct, let us see.

Used two different UDP Request all pointing to the DNS Server, used DNS JAVA Decoder Class, broke the load test in 3 scenarios **10** , **20** and **50**. This means we would have to update the number of threads in a thread group and keeping the ramp-up period to 10 sec.

![](https://cdn-images-1.medium.com/max/1024/1*hW6RFzhtSVoDyDoQsBie7A.png)<figcaption>Apache JMeter</figcaption>

to follow up on perfMon Metrics collector, you can find the details [here](https://jmeter-plugins.org/wiki/PerfMon/) and [here](https://github.com/undera/perfmon-agent), download the latest release, and start the client on your DNS Server.

**Note:** to be able to run Perfmon Metrics collector on the Raspberry PI, we would need compatible arm based .so lib, which can be found at the link below, Thanks to [RHQ](https://twitter.com/RHQ_Project) for all their hard work. [_https://sourceforge.net/projects/rhq/files/rhq/misc/_](https://sourceforge.net/projects/rhq/files/rhq/misc/)

```
wget [https://master.dl.sourceforge.net/project/rhq/rhq/misc/libsigar-arm-linux.so](https://master.dl.sourceforge.net/project/rhq/rhq/misc/libsigar-arm-linux.so)
```

**50 thread over 5 mins load test (over-Wifi);**

![](https://cdn-images-1.medium.com/max/1024/1*pU78YO_RR2lOWAbQY2liXw.png)<figcaption>majority of the responses were under 200ms, with occasional spikes reaching around 1000ms</figcaption>

![](https://cdn-images-1.medium.com/max/1024/1*gY7qGq4qj3k8vljgVM_QwA.png)<figcaption>response time distribution also concludes the same.</figcaption>

_Initially, wanted to see how well would RPI do at 50 and see If we could go higher, and up our test cases, sadly my router kept on restarting then I realized my Wifi_ 😵 _was the bottleneck, in real life I doubt my setup would create that much load, I have switched to ethernet now, but the results over Wifi, were interesting as well.  
RPI DNS server is serving at two points one is at ethernet and other wifi, only my test machine is using Ethernet, which was using Wifi before._

**10 thread over 5 mins 3000 requests/sec;**

![](https://cdn-images-1.medium.com/max/1024/1*EBwsa0nQ2dpPyEvLii8goQ.png)<figcaption>request per second</figcaption>

![](https://cdn-images-1.medium.com/max/1024/1*zhWJuNFGq35_ehZvFmb-EA.png)<figcaption>response time (ms)</figcaption>

![](https://cdn-images-1.medium.com/max/1024/1*j_v3T131FOW7QEkPh5zA3g.png)<figcaption>Memory(blue) is constant, CPU(red)</figcaption>

3000 requests per second. The error rate is 0.00% 😅, of total 1677107 samples. It did not impact memory much, query times are quick, a wired connection has made a difference and it seems RPI, still has a lot of room left. let’s double up the thread count and increase the requests slightly.

**20 thread over 5 mins 4500 requests/sec;**

![](https://cdn-images-1.medium.com/max/1024/1*LLS5WbdxRgad_Dd1Ld1SoA.png)<figcaption>requests per second</figcaption>

![](https://cdn-images-1.medium.com/max/1024/1*Y5jt4QYLzzGeL-w63mvy1g.png)<figcaption>response time (ms)</figcaption>

no more spike in request per second further down the line and the error rate is still 0.00% of total 2308031 sample size.

![](https://cdn-images-1.medium.com/max/1024/1*9XksxDUU4RMdRo1wj8QItg.png)<figcaption>CPU(red) has increased</figcaption>

![](https://cdn-images-1.medium.com/max/1024/1*Iq00HNJLNKbA29P_YqImOA.png)<figcaption>failures per request</figcaption>

**50 thread over 5 mins 6500–7000 requests/sec;**

![](https://cdn-images-1.medium.com/max/1024/1*TpjGIUOCdp8-XEpe-p80QA.png)<figcaption>requests per second</figcaption>

![](https://cdn-images-1.medium.com/max/1024/1*BpNIEm3bX64bnhvRO9aAeg.png)<figcaption>response time (ms)</figcaption>

![](https://cdn-images-1.medium.com/max/1024/1*UqrzqkRel7NyqMz1dLmTew.png)<figcaption>CPU(red) has increased</figcaption>

RPI consuming 7000 requests per second and not even burping, and the error rate is rock steady 0.00% of total 2939579 samples, I feel the more load we put on this arm based mean machine, more stable and faster it is, does putting more load on RPI3 sent it in overdrive mode? 🤩💥

![](https://cdn-images-1.medium.com/max/1024/1*EghEi1dPi4SMD3MO4zlWiw.png)

On side, it is interesting how all 4 cores of RPI are being used to maximize the utilization, hats of to ARM Community.

_Note: memory usage is still the same around 18mb, recorded by PerfMon, in the above image taken from HTOP system process usage is included._

Would you blame me If I tried putting more load to see if it can break? We are far beyond normal usage, now we are just trying to break it.

![](https://cdn-images-1.medium.com/max/480/1*kpHy0BeSNnqsY_atr4PAbg.gif)

OK, so we have some interesting results, threads were increased to 100, and requests were increased to 10000 per second, total samples 3343290, error rate still 0.00% compared to the volume of the request, it must be further down the decimal spaces. The CPU usage was about to hit 70%, the memory still did not move from 18mb.

![](https://cdn-images-1.medium.com/max/1024/1*Q3jE5P7nxynsAuKk0owEfQ.png)<figcaption>CPU(red) increasing</figcaption>

![](https://cdn-images-1.medium.com/max/1024/1*eoF_hI1xx6WQYx0Q8rD4BQ.png)<figcaption>in HTOP, all cores are perfectly utilized, perfmon showing average CPU usage</figcaption>

![](https://cdn-images-1.medium.com/max/1024/1*wr4ctMIk0XRmwJ4XCuJu7g.png)<figcaption>negligible failed requests per second</figcaption>

![](https://cdn-images-1.medium.com/max/1024/1*oSzYrhhl4vnKohT8S2hOmA.png)<figcaption>request per second</figcaption>

![](https://cdn-images-1.medium.com/max/1024/1*lnGwpnfti1U1HMFZ3XVYng.png)<figcaption>active threads</figcaption>

![](https://cdn-images-1.medium.com/max/1024/1*Up-Es8w1oSvDHeuYxD6OJQ.png)<figcaption>response time (ms)</figcaption>

![](https://cdn-images-1.medium.com/max/500/1*ClU_EyG6tknbf3eHGH_0Dg.gif)

Although at the end of the test, it can clearly be seen, that RPI was struggling but it just goes to show how stable and powerful RPI platform is. ~10000 requests, that is freaking fantastic. ARM Platforms, 5v power consumption can return this much value for money, is staggering 😱. Can you wonder what we can achieve if we had a cluster of them?

I use Raspberry PI’s for all kind of servers at home I have RPI2 and 1 as well, running different kinds of server ranging from python, java, and mono, And only if you knew how much punishment my RPI2 has to endure you would deeply feel sorry for it. One more thing if you are already following the latest news, docker is also supported👏. Future for ARM-based platform looks quite bright to me.