Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/balucio/dnsmasq-webgui

Simple web gui for dnsmasq
https://github.com/balucio/dnsmasq-webgui

dnsmasq python react-hooks systemd-notify typescript webgui

Last synced: 3 months ago
JSON representation

Simple web gui for dnsmasq

Awesome Lists containing this project

README

        

## *dnsmasq* Web Gui

This is a very simple project written in *Python* and *React* in order to manage the **dnsmasq** *hosts* file.

There are two folders:

- `dns-backend`: contains the API written in python using Flask framework, and some others tools to sync the DNS hosts file.
- `dns-webgui` folder contains the web gui itself. The Webgui is written in typescript using React Hooks.

### Web-Gui

Actually the web-gui it is a very simple React application. It present all hosts in browser using a table with classic web editing button.

In order to use the Web-Gui, first of all you need to compile React application using `yarn build` command. Then put the compiled application (files created in build directory) on the root directory or other directory of WebServer.

### Dns-Backend

The back-end is a Python application that use *flask* framework. The *dns-backend* uses an **sqlite3** database file in order to keep the list of DNS names (actually only `A` and `AAAA` records). All editing operation are performed on `hosts.db` **sqlite3** database file. The hosts file of *dnsmasq* is never directly updated.

### Tools and sync service

Inside `dns-backend` folder, there are some others scripts and **systemd** descriptors files. These files are used in order to update the **dnsmasq** hosts file with modifications made on *web-gui*.

- `dnsapplyconfig.sh` it is a bash script used to apply the new configuration and restart `dnsmasq` service. This script will generate a new `hosts` file for **dnsmasq**, then copy the new file on DNS server using `scp`, and then using `ssh` restart the service. You have to edit this script and change the line `dns_host="dns.example.it"` using the *hostname* or ip address of your DNS server. Also it is required a *passwordless* `ssh`, so that the computer where the script runs can connect to DNS server without password.
- `dnsmasq-genhosts.py` this python script is used by `dnsapplyconfig.sh` in order to create a new `hosts` file from the **sqlite3** `hosts.db` database.
- `dnsmonitor.path`: it is a **systemd** descriptor *path* used to keep monitored the `/var/www/cgi-bin/dnsapi/hosts.db` for modifications.

- `dnsmonitor.service`: it is the **systemd** descriptor *service* triggered by `dnsmonitor.path` when a change to `hosts.db` occurs. This service will run the `dnsapplyconfig.sh` script in order to update the dns configuration.

### Compilation

Here a very short guide on how to compile the _front-end_

```bash
git clone https://github.com/balucio/dnsmasq-webgui.git
cd dnsmasq-webgui/dns-webgui
# this will install the dependency
yarn install
# this will build the compiled web application, take a break because it requires time
yarn build
```

For latest `yarn` version you should add :

```
export NODE_OPTIONS=--openssl-legacy-provider
npx update-browserslist-db@latest
```
see [Stackoverflow](https://stackoverflow.com/questions/69394632/webpack-build-failing-with-err-ossl-evp-unsupported)

At end you should find the compiled application in build directory, you can test it using

```
DANGEROUSLY_DISABLE_HOST_CHECK=true yarn start
```