-
Notifications
You must be signed in to change notification settings - Fork 22
Setting up dnsmasq with secureoperator
Since secureoperator does no caching of its own, it's recommended that you set up a caching DNS server like dnsmasq on your local network, which responds from its own cache and forwards uncached requests to secureoperator for lookup.
This document assumes that you:
- are setting up dnsmasq and secureoperator on the same machine
- have already installed the dnsmasq package as apropriate for your operating system
- are installing on a Linux system
- are using systemd
This isn't the only way to do this (you could use Docker, for example) however these instructions should easily adapt to other environments.
- Download the latest release of secureoperator for your environment, and place it at
/usr/local/bin/secure-operator
. Ensure it is executable (chmod +x secure-operator
) - Create a systemd unit file to run secureoperator on startup. Save this file as
/etc/systemd/system/secure-operator.service
and ensure it is executable (chmod +x secure-operator.service
)
[Unit]
Description=Secure Operator
After=network.target
[Service]
Type=simple
# start secureoperator on port 54, rather than the standard DNS port. dnsmasq will run on 53 and
# forward to this server.
ExecStart=/usr/local/bin/secure-operator -level warn -listen 0.0.0.0:54 -dns-servers "8.8.8.8,8.8.4.4"
[Install]
WantedBy=multi-user.target
- Run
systemctl daemon-reload
to reload the unit files - Run
systemctl start secure-operator.service
- If secureoperator starts successfully, enable the service with
systemctl enable secure-operator.service
; it will now run at startup.
Make a DNS request directly at secureoperator to ensure it's working; with the dig
command:
dig @localhost -p 54 google.com
You should see a response which includes the A
records for google.com
.
dnsmasq has a lot of configuration options; you should refer to its man
page for information on each; however, you a minimal configuration should only require a few tweaks.
- Edit
/etc/dnsmasq.conf
, ensure the following lines are set as follows:
# stops dnsmasq from reading resolv.conf
no-resolv
# add your secureoperator server as the upstream dns server
server=127.0.0.1#54
# set how many entries you wish to have cached; you can tweak
# this setting depending on how much memory your sytem has
# available
cache-size=500
- Alter the dnsmasq unit file to depend on secureoperator;
/etc/systemd/system/dnsmasq.service
; add the following to the[Unit]
section. Ensure these are new additions; don't replace any of the existingAfter
orRequires
directives:
After=secure-operator.service
Requires=secure-operator.service
- Reload the unit file with
systemctl daemon-reload
- Start dnsmasq with
systemctl start dnsmasq.service
- If it starts correctly, enable it at startup with
systemctl enable dnsmasq.service
Make a DNS request against dnsmasq to ensure it's working; with the dig
command:
dig @localhost google.com
You should see a response which includes the A
records for google.com
.
Above, we opted to run secureoperator's logs at the warn
level; this is because you probably don't want securoperator writing every DNS lookup you make to logs, which is what it does at the default info
level. However, if you want to ensure things are working as appropriate, you'll need to see those logs:
- Alter the
ExecStart
line in/etc/systemd/system/secure-operator.service
to log at the info level:
ExecStart=/usr/local/bin/secure-operator -level info -listen 0.0.0.0:54 -dns-servers "8.8.8.8,8.8.4.4"
- Reload unit files
systemctl daemon-reload
- Restart secureoperator with
systemctl restart secure-operator.service
- Follow the secure operator logs with
journalctl -f "_SYSTEMD_UNIT=secure-operator.service"
- Now make some requests against DNS to see if behavior is as expected
What are you looking for?
- You should see secureoperator being hit for each fresh lookup of a domain
- You should not see any subsequent hits against secureoperator for any domain whose cache has not expired yet
You can tell how long a record should be cached for in the ANSWER
section of dig
's output:
;; ANSWER SECTION:
google.com. 299 IN A 74.125.28.100
google.com. 299 IN A 74.125.28.139
google.com. 299 IN A 74.125.28.102
google.com. 299 IN A 74.125.28.113
google.com. 299 IN A 74.125.28.101
google.com. 299 IN A 74.125.28.138
In the above example, 299
is the cache timeout value, in seconds.
Note: be sure to lower the log level of secureoperator back to warn
when you are done testing.