# Compiling Unbound from Source / Getting Unbound to work with DNS-over-TLS?

**URL:** <https://discourse.pi-hole.net/t/compiling-unbound-from-source-getting-unbound-to-work-with-dns-over-tls/19017>\
**Category:** Help\
**Created:** [April 8, 2019, 12:00am UTC](https://discourse.pi-hole.net/t/compiling-unbound-from-source-getting-unbound-to-work-with-dns-over-tls/19017 "2019-04-08T00:00:35Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jpgpi250](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/jpgpi250/32/286_2.png) [@jpgpi250](https://discourse.pi-hole.net/u/jpgpi250)\
**Post date:** [April 8, 2019, 7:02am UTC](https://discourse.pi-hole.net/t/compiling-unbound-from-source-getting-unbound-to-work-with-dns-over-tls/19017/2 "2019-04-08T07:02:48Z")

</div>

´edit´  
This only works if unbount **isn't** already on your system, uninstall & purge older versions before continuing!  
`/edit`

compile:

```auto
#!/bin/bash

sudo apt-get -y install libssl-dev
sudo apt-get -y install libexpat1-dev

sudo groupadd -g 991 unbound
sudo useradd -c "unbound-1.9.1" -d /var/lib/unbound -u 991 -g unbound -s /bin/false unbound

file=unbound-1.9.1
mkdir -p unbound
cd unbound
wget https://nlnetlabs.nl/downloads/unbound/$file.tar.gz
tar xzf $file.tar.gz 
cd $file

sudo ./configure --prefix=/usr --sysconfdir=/etc --disable-static --with-pidfile=/run/unbound.pid
sudo make
sudo make install
cd ..
cd ..

```

dnssec:

```auto
# dnssec
sudo chown unbound:unbound /etc/unbound
sudo /usr/sbin/unbound-anchor -a /etc/unbound/root.key -v

```

remote control:

```auto
#remote control
sudo /usr/sbin/unbound-control-setup

```

create `/lib/systemd/system/unbound.service`, content:

```auto
Description=Validating, recursive, and caching DNS resolver
Documentation=man:unbound(8)
Requires=network.target
After=network.target
Before=network-online.target nss-lookup.target
Wants=nss-lookup.target

[Install]
WantedBy=multi-user.target

[Service]
ExecStartPre=-/usr/sbin/unbound-anchor -a /etc/unbound/root.key -v
ExecStart=/usr/sbin/unbound -d -v
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
RestartSec=360

```

systemctl:

```auto
sudo systemctl daemon-reload
sudo systemctl enable unbound.service
sudo systemctl start unbound.service

```

---

_[View the full topic](https://discourse.pi-hole.net/t/compiling-unbound-from-source-getting-unbound-to-work-with-dns-over-tls/19017)._
