diff options
| author | Franck Cuny <franck@fcuny.net> | 2023-04-06 17:37:27 -0700 |
|---|---|---|
| committer | Franck Cuny <franck@fcuny.net> | 2023-04-06 19:21:17 -0700 |
| commit | 9516b633fa651875503bb61b5194bfb7e5f409e3 (patch) | |
| tree | bc63b50a4f78ca72976d27a6cee6f4ca2301e213 /tools/dnsmasq-leases-html/README.md | |
| parent | monitoring: small fixes (diff) | |
| download | infra-9516b633fa651875503bb61b5194bfb7e5f409e3.tar.gz | |
tools/dnsmasq-leases-html: create a HTML page with leases from dnsmasq
Parse the file that contains all the leases assigned by dnsmasq, and
create a static HTML page from it. This can be served by nginx to make
it easy to see what IP is assigned to a machine, and which machines are
currently on the network.
Diffstat (limited to '')
| -rw-r--r-- | tools/dnsmasq-leases-html/README.md | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tools/dnsmasq-leases-html/README.md b/tools/dnsmasq-leases-html/README.md new file mode 100644 index 0000000..2437deb --- /dev/null +++ b/tools/dnsmasq-leases-html/README.md @@ -0,0 +1,37 @@ +Generates a static HTML page with a list of all the leases allocated by `dnsmasq`. + +A simple template written in the jinja syntax is used. + +The file containing the leases is expected to be at `/var/lib/dnsmasq/dnsmasq.leases`, but this can be overwritten by setting the environment variable `DNSMASQ_LEASES`. + +The output of the script is written to `/var/lib/dnsmasq/leases.html` by default, but the destination can be overwritten by setting the environment variable `DNSMASQ_LEASES_OUT`. + +The script can be executed automatically by `dnsmasq` if the configuration for `dhcp-script` is set to the path of the script. This will only be executed when a *new* lease is created or an *old* lease is deleted. To execute the script when a lease is *updated* you need to use the configuration `script-on-renewal`. + +A configuration looks like this: + +``` ini +dhcp-script=${pkgs.tools.dnsmasq-to-html}/bin/dnsmasq-leases-html +script-on-renewal +``` + +## nginx +To serve the page with nginx, you can use the following configuration: + +``` nix +services.nginx = { + enable = true; + virtualHosts."dnsmasq" = { + listen = [ + { + addr = "192.168.6.1"; + port = 8067; + } + ]; + locations."/" = { + root = "/var/lib/dnsmasq"; + index = "leases.html"; + }; + }; +}; +``` |
