summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason D. McCormick <jason@mfamily.org>2019-03-15 19:10:27 -0400
committerJason D. McCormick <jason@mfamily.org>2019-03-15 19:10:27 -0400
commit13aa7a179e39835b25c61c2c7f2b7acc886b4f0f (patch)
tree99c250b77950852be8748b86d105ef4512d81fcc
parentc9245cb0c2a0cd4b8e17a20c76a21b7adb98b871 (diff)
Add IP overrides
-rw-r--r--README.md24
-rwxr-xr-xhe-dyndns19
2 files changed, 34 insertions, 9 deletions
diff --git a/README.md b/README.md
index 1541c8e..bea978a 100644
--- a/README.md
+++ b/README.md
@@ -25,17 +25,31 @@ program, ensure proper security is applied to this file.
**he-dyndns** takes the following options:
## Requied Options
-- **-4**: Update the IPv4 "A" record for the FQDN(s)
-- **-6**: Update the IPv6 "AAAA" record for the FQDN(s).
+- **-4**: Update the IPv4 "A" record for the FQDN(s). Note that to use this option,
+the system making the call must be able to reach dyn.dns.he.net with an IPv4 address.
+NAT is okay. Without using **-a** then the public address or public NAT address is
+what is set for the FQDN(s).
+
+- **-6**: Update the IPv6 "AAAA" record for the FQDN(s). Note that to use this option,
+the system making the call must be able to reach dyn.dns.he.net with an IPv6 address.
+
- **-d**: One or more fully-qualified host entries for the domain separated by commas
Note that one or both of -4 and -6 must be specified for the script to
-actually do anything.
+actually do anything. Not specifing at least one of them will result in a
+successful script exit with no actions being taken.
## Optional Options
-- **-s**: The secret key for updating the entries
+- **-a**: Use the supplied IPv4 address instead of allowing HE DNS to auto-set
+based on source. Note that the address is not validated for well-formedness.
+
+- **-A**: Use the supplied IPv6 address instead of allowing HE DNS to auto-set
+based on source. Note that the address is not validated for well-formedness.
+
+- **-s**: The secret key for updating the entries. This overrides any
+existing /etc/he-dns-secret file, if one exists.
-Any other unsupported option or no options will print a usage message
+Any other unsupported option or no options will print a usage message.
# Return Values
Returns 0 on success or 1 on failure. Failure message returns the exact error
diff --git a/he-dyndns b/he-dyndns
index 3647c67..0ce3730 100755
--- a/he-dyndns
+++ b/he-dyndns
@@ -12,7 +12,12 @@ usage() { echo "Usage: $0 [-s SECRET] -d HOSTNAME[,HOSTNAME,...]" 1>&2; exit 1;
## DO THE UPDATE FUNCTION ONCE FOR HAPPY EDITING ##
doUpdate() {
- /usr/bin/curl -s$1 "https://$FQDN:$CODE@$DNSSITE/nic/update?hostname=$FQDN" > $tfile
+
+ if [ ! -z $2 ]; then
+ myip="&myip=$2"
+ fi
+
+ /usr/bin/curl -s$1 "https://$FQDN:$CODE@$DNSSITE/nic/update?hostname=$FQDN$myip" > $tfile
if ! egrep -q '(good|nochg)' $tfile; then
echo -n "v$1 change: "
cat $tfile
@@ -22,7 +27,7 @@ doUpdate() {
}
## MAIN ##
-while getopts "46hd:s:" arg; do
+while getopts "46a:A:hd:s:" arg; do
case "${arg}" in
4)
DO4=Y
@@ -30,6 +35,12 @@ while getopts "46hd:s:" arg; do
6)
DO6=Y
;;
+ a)
+ ADDR4=${OPTARG}
+ ;;
+ A)
+ ADDR6=${OPTARG}
+ ;;
d)
FQDNS=${OPTARG}
;;
@@ -66,11 +77,11 @@ tfile=$(/bin/mktemp)
for FQDN in $(echo $FQDNS | tr ',' ' ')
do
if [ ! -z ${DO4} ]; then
- doUpdate 4
+ doUpdate 4 ${ADDR4}
fi
if [ ! -z ${DO6} ]; then
- doUpdate 6
+ doUpdate 6 ${ADDR6}
fi
done