A high availability dnsmasq deployment with web UI for edit hosts file.
This is a common problem if you want to set up dns server all by yourselves.
This project contains two parts:
- web based edit tool for hosts file, it will save the hosts record in sqlite 3 data base and generate a hosts file at /etc/dnsmasq-ha-web/hosts
- a configuration based on lsyncd and rsync for remote hosts file synchronization, which make sure the hosts file for dnsmasq servers is on sync
You can either install the dnsmasq-ha-web server with a standalone instance or install it with one of your dnsmasq instance. The script make sure there is no conflict.
-
Config no password sudo permission to remote server, because we need to restart dnsmasq remotely
echo "ubuntu ALL=(ALL) NOPASSWD:ALL" | sudo EDITOR='tee -a' visudo
-
Install required packages
sudo apt install dnsmasq rsync
-
Copy the dnsmasq config in
scripts/etc/dnsmasq.d/ha-web.conf
to/etc/dnsmasq.d/ha-web.conf
-
Copy the scripts from
scripts/local/bin/dnsmasq-rsync.sh
to/local/bin/dnsmasq-rsync.sh
-
Change the permission of the script file
sudo chmod +x /local/bin/dnsmasq-rsync.sh
-
Create the dir to add hosts file
sudo mkdir -p /etc/dnsmasq sudo touch /etc/dnsmasq/hosts
-
Install lsyncd and rsync
sudo apt install -y lsyncd rsync
-
Generate ssh key access and upload to dns servers
sudo mkdir -p /etc/lsyncd sudo ssh-keygen -t rsa -f /etc/lsyncd/id_rsa ssh-copy-id -i /etc/lsyncd/id_rsa.pub <your user>@<your remote server>
-
Copy the config file in
scripts/etc/lsyncd/lsyncd.conf.lua
to the destination/etc/lsyncd/lsyncd.conf.lua
-
Restart lsyncd service
sudo service lsyncd restart
-
Copy the binary build in this repo to the destination
bin/dnsmasq-ha-web
->/usr/local/bin/dnsmasq-ha-web
-
Copy the service config file in
scripts/etc/systemd/system/dnsmasq-ha-web.service
->/etc/systemd/system/dnsmasq-ha-web.service
-
Start the service and check the status
sudo systemctl daemon-reload sudo service dnsmasq-ha-web start
-
Build the web frontend
cd frontend yarn install yarn build
-
Build the go application, you need gcc installed, since this application is based on sqlite3 and the go-sqlite3 package need CGO enabled
make build