Skip to content

Instantly share code, notes, and snippets.

@HouCoder
Created March 12, 2020 02:56

Revisions

  1. HouCoder created this gist Mar 12, 2020.
    18 changes: 18 additions & 0 deletions duckdns.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #!/bin/bash

    domain="duckdns.org"
    name="example-a-record"
    token="your token"
    # Get public IP from ipinfo.io
    public_ip="$(curl --silent ipinfo.io/ip)"

    # get current record
    current_record="$(dig @8.8.8.8 +short $name.$domain)"

    if [ "$current_record" != "$public_ip" ]; then
    echo New public IP is $public_ip

    curl "https://www.duckdns.org/update?domains=$name&token=$token&ip=$public_ip"
    else
    echo Nothing changed
    fi