Socket
Socket
Sign inDemoInstall

github.com/rclsilver-org/usg-dns-api

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/rclsilver-org/usg-dns-api


Version published
Created
Source

usg-dns-api

usg-dns-api is a program that exposes an API for managing DNS records on Ubiquiti routers. It interacts with the Unifi Controller and builds a hosts file based on the following:

  • Static IP addresses configured by the router administrator.
  • DNS records defined via the API.

Reverse records are also automatically generated.

Installation

  1. Download the .deb file from the GitHub releases using curl:

    curl -L https://github.com/rclsilver-org/usg-dns-api/releases/download/<version>/usg-dns-api_<version>_mips.deb -o usg-dns-api_mips.deb
    
  2. Install the .deb package:

    sudo dpkg -i usg-dns-api_mips.deb
    
  3. Edit the configuration file located at /etc/usg-dns-api/usg-dns-api.yaml to suit your environment.

  4. Generate a token for API access:

    sudo usg-dns-api generate-token
    
  5. Enable the service to start at boot:

    sudo update-rc.d usg-dns-api defaults
    
  6. Start the service:

    sudo /etc/init.d/usg-dns-api start
    

Persistent dnsmasq Configuration

To configure dnsmasq persistently on Ubiquiti routers, edit the config.gateway.json file and add the following configuration:

{
  "service": {
    "forwarding": {
      "options": [
        "server=8.8.8.8",
        "server=8.8.4.4",
        "all-servers",
        "no-hosts",
        "addn-hosts=/config/user-data/hosts",
        "domain-needed",
        "bogus-priv",
        "expand-hosts",
        "domain=local.example.com",
        "local=/local.example.com/"
      ]
    }
  }
}

API Usage Examples

  • List all DNS records:

    curl -i -H "Authorization: <master-token>" http://<router>:8080/records
    
  • Add a DNS record:

    curl -i -H "Authorization: <master-token>" -X POST http://<router>:8080/records -d '{"name": "foo", "target": "127.0.0.1"}'
    
  • Update a DNS record:

    curl -i -H "Authorization: <master-token>" -X PUT http://<router>:8080/records/<id> -d '{"name": "foo", "target": "127.0.0.1"}'
    
  • Delete a DNS record:

    curl -i -H "Authorization: <master-token>" -X DELETE http://<router>:8080/records/<id>
    

This API allows you to easily manage DNS records through a simple HTTP interface with the token-based authentication for secure access.

FAQs

Package last updated on 20 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc