All Projects → evaneaston → udm-host-records

evaneaston / udm-host-records

Licence: MIT license
Scripts to list, add, update, and remove host records in the Ubiquiti UniFI Dream Machine DNS forwarder.

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to udm-host-records

node-unifi
NodeJS class for querying/controlling a UniFi-Controller (www.ubnt.com)
Stars: ✭ 92 (-15.6%)
Mutual labels:  unifi, ubiquiti, udm, udm-pro
udm-patches
Contains onboot.d setup scripts and wrappers for custom OpenVPN client
Stars: ✭ 42 (-61.47%)
Mutual labels:  unifi, ubiquiti, udm, udm-pro
udm-utilities
A collection of things I have made to make the Unifi Dream Machine more useful
Stars: ✭ 2,228 (+1944.04%)
Mutual labels:  unifi, ubiquiti, udm, udm-pro
unifiZabbix
Zabbix templates to monitor pretty much all Unifi devices
Stars: ✭ 66 (-39.45%)
Mutual labels:  unifi, ubiquiti, udm, udm-pro
unpoller
Application: Collect ALL UniFi Controller, Site, Device & Client Data - Export to InfluxDB or Prometheus
Stars: ✭ 1,613 (+1379.82%)
Mutual labels:  unifi, ubiquiti, udm
udm-kernel-tools
Tools for bootstrapping custom kernels on the UniFi Dream Machine
Stars: ✭ 211 (+93.58%)
Mutual labels:  unifi, udm, udm-pro
Devdns
Automagic Docker DNS for local development
Stars: ✭ 99 (-9.17%)
Mutual labels:  dns, dnsmasq
Glider
glider is a forward proxy with multiple protocols support, and also a dns/dhcp server with ipset management features(like dnsmasq).
Stars: ✭ 1,710 (+1468.81%)
Mutual labels:  dns, dnsmasq
Elk Hole
elasticsearch, logstash and kibana configuration for pi-hole visualiziation
Stars: ✭ 136 (+24.77%)
Mutual labels:  dns, dnsmasq
Sysuv6 Dns
May be the best DNS in SYSU.
Stars: ✭ 142 (+30.28%)
Mutual labels:  dns, dnsmasq
Dns Proxy
Simple DNS Proxy written in Node.JS. Override hosts, domains, or tlds. Redirect certain domains to different nameservers.
Stars: ✭ 165 (+51.38%)
Mutual labels:  dns, dnsmasq
Dnsmasqweb
基于DNSmasq的DNS解析、以及DHCP地址分配系统
Stars: ✭ 166 (+52.29%)
Mutual labels:  dns, dnsmasq
Hblock
Improve your security and privacy by blocking ads, tracking and malware domains.
Stars: ✭ 724 (+564.22%)
Mutual labels:  dns, dnsmasq
Roguesploit
Powerfull Wi-Fi trap!
Stars: ✭ 262 (+140.37%)
Mutual labels:  dns, dnsmasq
Hosts Blocklists
Automatically updated, moderated and optimized lists for blocking ads, trackers, malware and other garbage
Stars: ✭ 1,749 (+1504.59%)
Mutual labels:  dns, dnsmasq
ansible-dnsmasq
Ansible role to set up Dnsmasq in Debian-like systems
Stars: ✭ 18 (-83.49%)
Mutual labels:  dns, dnsmasq
Blacklist
Blacklist and Adware Blocking for the Ubiquiti EdgeMax Router
Stars: ✭ 393 (+260.55%)
Mutual labels:  dnsmasq, ubiquiti
addon-unifi
UniFi Network Application - Home Assistant Community Add-ons
Stars: ✭ 190 (+74.31%)
Mutual labels:  unifi, ubiquiti
split-vpn
A split tunnel VPN script for Unifi OS routers (UDM, UXG, UDR) with policy based routing.
Stars: ✭ 589 (+440.37%)
Mutual labels:  udm, udm-pro
unifi2mqtt
Connect Ubiquiti UniFi controller to MQTT 📡
Stars: ✭ 66 (-39.45%)
Mutual labels:  unifi, ubiquiti

udm-host-records

Scripts to list, add, update, and remove host records in the Ubiquiti UniFI Dream Machine DNS forwarder.

DEPRECATED!!!!!

This was a brief attempt at providing local network DNS resolution. But because it's clear that the hostRecords are overwritten by Ubiquiti-owned code in a bunch of scenarios that don't seem to warrant it, it's clear that this approach to gaining a bit of local DNS control isn't sustainable. Please consider running your own local DNS, such as PiHole instead

Description

As of the creation of this repo, UDMs do not have a UI for administering host records. But the DNS forwarder running on the device supports them. If you don't already run your own DNS service and want to be able to resolve hosts by name in your UDM networks, you can add host records. But it's tedious.

The UDMs no longer resolve against the /etc/hosts file. Instead they use records that must be administered via API. You can edit them via code by GET'ting the /services endpoint to get the json response, changing the entries in dnsForwarder.hostRecords, and PUT'ting the the updated json back to the /services endpoint. This was well documented in this community topic.

These scripts should make the process a little easier.

Once scripts are executed

  • the changes take effect immediately
  • host records will persist restarts and become part of backups.

Verify Assumptions

  • Have you configured your local networks to use nameservers other than the UDM? If so, these scripts won't help you. You need to set each local network's DHCP Name Server to automatic or to the ip of the UDM. You can still use alternate DNS servers ouside your network. You will juat need to config your WAN networks to forward to these DNS servers.
  • These scripts do nothing with client aliases. While it wouldn't be a stretch to add a script that will capture all client aliases and the network domains and automatically register host records for each,that's not what these scripts do...yet ;)

Install

  1. Download - Clone this repo or use the Code > Download Zip github button to download a zip containing the repo code.
  2. Copy the code to the UDM to a directory of your choosing, such as /mnt/data/udm-host-records
  3. Make sure script execution permissions in case they didn't survive the download and copy. If they didn't then,
cd /mnt/udm-host-records
chmod u+x *.sh

Run

List Host Records

To see what host records are present, use

list-host-records.sh

Add or Change a Host Record

To create or update a host record, use

./add-host-record.sh {-f} {-v 4|6} <hostname>.<domain> <ipaddress>

  -f     FQDN only.  Sets registerNonQualified=false on the host record.  Defaults to true.
  -v     4 or 6.  Defaults to 4.  Ignored by UDM firmware < 1.9.
./add-host-record.sh coffee-machine.yourlocaldomain.com 192.168.8.43

will allow you to resolve your coffee-machine's IP address using coffee-machine.yourlocaldomain.com or just simply coffee-machine.

Just like in an /etc/hosts file, you can add multiple entries for any given IP.

If you want to change the IP of an existing host entry, run the command again with the new IP address.

Remove a Host Entry

To remove a host record, use

./remove-host-record.sh <hostname>.<domain>

Disclaimers / Warnings

  • This code makes no backups. Use at your own risk. MAKE YOUR OWN BACKUPS BEFORE USING
  • It relies on the UDM PUT /services API to validate the updated JSON it PUTs back to the API.
  • It may stop working at any time if Ubiquiti changes how the /services works or the structure of the json content it accepts.

Testing

To simplify development while I was tweaking the jq commands, I made a mock ubios-udapi-client script that I run locally when the TEST env var is set to 1. It will simply echo the testdata.json from the same directory as the scripts whenever the scripts GET the /services endpoint. It will also result in the changed json file being echo'ed to stdout whenever it PUTs the JSON to the '/services' endpoint.

If you want to experiment,

  1. get a copy of the /services config json by running the command ubios-udapi-client GET /services > testdata.json on your UDM. Place this testdata.json in the same directory as the scripts where you are going to edit and test them
    • NOTE THAT THIS MAY CONTAIN SENSITIVE INFORMATION IN PLAINTEXT FORM. SECURE AND RETAIN IT ACCORDINGLY.
  2. run the commands with TEST=1 before them, e.g.
TEST=1 ./list-host-records.sh ...
TEST=1 ./add-host-record.sh ...
TEST=1 ./remove-host-record.sh ...
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].