Deprecated: Function jetpack_form_register_pattern is deprecated since version jetpack-13.4! Use Automattic\Jetpack\Forms\ContactForm\Util::register_pattern instead. in /var/www/html/wp-includes/functions.php on line 6078 Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-includes/functions.php:6078) in /var/www/html/wp-includes/feed-rss2.php on line 8 Networking – D Khaz https://khaz.me Things that I spend my time on... Sat, 23 Jan 2021 21:40:58 +0000 en-US hourly 1 https://khaz.me/wp-content/uploads/2018/05/DK_logo_square___100x100.png Networking – D Khaz https://khaz.me 32 32 147286311 Configuring DuckDNS dynamic DNS on the Ubiquiti USG https://khaz.me/configuring-duckdns-dynamic-dns-on-the-ubiquiti-usg/ Wed, 10 Jun 2020 17:42:45 +0000 https://khaz.me/?p=350 I have a remote USG deployed at a relative’s house and need to have a way to access the UniFi Security Gateway’s WAN IP if the ISP changes it.

Steps to implement

  1. Create a user account on www.duckdns.org. This will generate a new user token. Save this as you will need it later and don’t share this.
  2. Create a subdomain on www.duckdns.org
  3. Go to your UniFi controller and set up a config.gateway.json file, instructions here.
  4.  Add the below configuration to this file. Replace SUBDOMAIN with just the subdomain of your duckdns site and replace TOKEN from your account token.
  5. Go to your UniFi Controller and reprovision your USG. Your dynamic DNS should now be working
{
  "service": {
    "dns": {
      "dynamic": {
        "interface": {
          "eth0": {
            "service": {
              "dyndns": {
                "host-name": [
                  "SUBDOMAIN"
                ],
                "login": "nouser",
                "password": "TOKEN",
                "server": "www.duckdns.org"
              }
            },
            "web": "dyndns"
          }
        }
      }
    }
  }
}

Check to make sure it works

To check and confirm the USG is updating the DNS correctly, you can SSH into the USG and run show dns dynamic status.

show dns dynamic status
interface    : eth0
ip address   : 123.123.123.123
host-name    : SUBDOMAIN
last update  : Wed Jun 10 12:08:20 2020
update-status: good

You can also force an update by running update dns dynamic interface eth0

]]>
350
Cloudflare DDNS configuration for Unifi USG https://khaz.me/cloudflare-ddns-configuration-for-unifi-usg/ https://khaz.me/cloudflare-ddns-configuration-for-unifi-usg/#comments Fri, 31 May 2019 21:36:17 +0000 https://khaz.me/?p=219

I’ve recently made the switch to using Cloudflare as my DDNS provider.  Unfortunately, Ubiquiti has not done a good job of expanding and updating its DDNS providers in the Unifi Controller.

Update USG ddclient

The USG firmware is using an older version of the ddclient which is no longer supported by cloudflare.  So, in order to get it to connect, you need to upgrade to the newer version.  Luckily, @troyfontaine has done all the heavy lifting and shared it with the worldGo buy him a beer.  You can perform the individual steps as shown in the script or execute the thing with curl.

#!/bin/bash
# Run this script as sudo

# Specify the repo and the location of the apt sources list
DEB_REPO="deb http://archive.debian.org/debian/ wheezy main # wheezy #"
APT_SRC="/etc/apt/sources.list"

# Add deb repo to sources list if it isn't there
grep -q -F "$DEB_REPO" "$APT_SRC" || echo "$DEB_REPO" >> "$APT_SRC"

# Run Apt update
apt-get update; apt-get -y install libdata-validate-ip-perl

# Download new ddclient and replace the existing version
cd /tmp
curl -L -O https://raw.githubusercontent.com/ddclient/ddclient/master/ddclient
cp /usr/sbin/ddclient /usr/sbin/ddclient.bkp
cp ddclient /usr/sbin/ddclient
chmod +x /usr/sbin/ddclient

# Tell the USG to update configuration and then display the status
# Run the following manually to update your DDNS record:
# update dns dynamic interface eth2 && sleep 20 && show dns dynamic status

curl https://gist.githubusercontent.com/troyfontaine/7e6f93e32621177fc9a94e823adc52b5/raw/fix_ddns.sh | sudo bash

Testing the configuration

Before permanently making this configuration, I wanted to test my settings.  Below are the configuration commands used to enable this by SSH’ing into your USG. The zone should match the zone name in CF and the password is the API Zone ID that’s listed on the overview page.

set service dns dynamic interface eth2 service cloudflare host-name khaz.me
set service dns dynamic interface eth2 service cloudflare login my@email.com
set service dns dynamic interface eth2 service cloudflare options zone=khaz.me
set service dns dynamic interface eth2 service cloudflare password 4jdGtFnlBwuneXmv6mdvc2nbhm4DZLYY
set service dns dynamic interface eth2 service cloudflare protocol cloudflare
set service dns dynamic interface eth2 service cloudflare server api.cloudflare.com/client/v4
set service dns dynamic interface eth2 web dyndns

If you are unfamiliar how to do this, you can learn more from Ubiquiti’s instructions for EdgeRouters which use the same tools.  I like to use the commit-confirm 5 option in case I’ve messed up any entries through the CLI.  Keep in mind, this configuration will not survive re-provisioning of the USG from the controller as the controller does not have these settings.

poldim@USGPro:~$ update dns dynamic interface eth2 && sleep 20 && show dns dynamic status
interface    : eth2
ip address   : 66.119.21.125
host-name    : khaz.me
last update  : Fri May 31 13:40:04 2019
update-status: good

Permanent Configuration

After having my settings on for a week, I decided to configure these settings.  You will need to follow the USG Advanced Configuration process as outlined by Ubiquiti.

{
  "service": {
    "dns": {
      "dynamic": {
        "interface": {
          "eth2": {
            "service": {
              "cloudflare": {
                "host-name": [
                  "khaz.me"
                ],
                "login": "my@email.com",
                "options": [
                  "zone=khaz.me"
                ],
                "password": "4jdGtFnlBwuneXmv6mdvc2nbhm4DZLYY",
                "protocol": "cloudflare",
                "server": "api.cloudflare.com/client/v4"
              }
            },
            "web": "dyndns"
          }
        }
      }
    }
  }
}

]]>
https://khaz.me/cloudflare-ddns-configuration-for-unifi-usg/feed/ 12 219