Initial Commit
commit
31e2d1f931
@ -0,0 +1,28 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2023, Jay Moore
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@ -0,0 +1,72 @@
|
||||
# HE Dynamic DNS Updater
|
||||
|
||||
This script will update A and AAAA records on Hurricane Electric's DNS
|
||||
for hosts with DDNS enabled. It will pull your IPv4 from a source and
|
||||
your IPv6 from the local machine.
|
||||
|
||||
It also includes two files, getv4.php and getv4.sh; which will allow
|
||||
you to run your own IP check service for IPv4 on a pfSense box if it
|
||||
also has the public v4 you want to use. If it's behind a bridge or
|
||||
DMZ, you'll have to use an external service.
|
||||
|
||||
## Installation & Usage
|
||||
|
||||
If you are using the pfSense IP Check Service, copy both the .sh and
|
||||
.php file in to /usr/local/www. It will be available at
|
||||
|
||||
- https://[LAN.IP]/getv4.php
|
||||
- http://[LAN.IP]/getv4.php
|
||||
|
||||
depending on if you use https or not.
|
||||
|
||||
Copy hedyn.sh to your server using the hostname; then make a copy
|
||||
of it if you're updating/hosting multiple names. Edit the script
|
||||
with your hostname, APIKey, the device you want to use for IPv6,
|
||||
and which IPv4 check service you want to use. Add it to cron.
|
||||
|
||||
The script will only update either v4 or v6 if the records don't
|
||||
match the machine's IP addresses.
|
||||
|
||||
To use with just v4 or just v6; comment out the appropiate parts.
|
||||
|
||||
## Caution
|
||||
|
||||
This comes with no warranty. Any usage or modification to pfSense
|
||||
is done at your own risk.
|
||||
|
||||
## Changelog
|
||||
|
||||
```
|
||||
10-APR-2023: Initial Version
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2023, Jay Moore
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@ -0,0 +1,12 @@
|
||||
/*
|
||||
GetV4: Check IP Service for pfSense
|
||||
10-APR-2023 - dewdude@pickmy.org
|
||||
https://git.pickmy.org/dewdude/HEDyn
|
||||
*/
|
||||
|
||||
// Place this file along with getv4.sh in /usr/local/www
|
||||
|
||||
<?php
|
||||
$output = shell_exec('/usr/local/www/getv4.sh');
|
||||
echo "$output";
|
||||
?>
|
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
# GetV4 IP Check Service for pfSense - shell script
|
||||
# APR-10-2023 - Jay Moore (dewdude@pickmy.org)
|
||||
# https://git.pickmy.org/dewdude/HEDyn
|
||||
|
||||
# Modify "em0" to match your interface name. Place in
|
||||
# /usr/local/www along with getv4.php.
|
||||
|
||||
# Make sure script is +x
|
||||
|
||||
ifconfig em0 | grep inet | awk -F '[ \t]+|/' '{print $3}' | grep -v ^fe80
|
@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
# HEDDNS Update Script
|
||||
# 10-APR-2023 - Jay Moore (dewdude@pickmy.org)
|
||||
# https://git.pickmy.org/dewdude/HEDyn
|
||||
# FreeBSD 3-Clause License (see LICENSE)
|
||||
|
||||
# Hostname & APIKey Configuration:
|
||||
hostname=DDNSHOSTNAME
|
||||
APIkey=HOSTNAMEAPIKEY
|
||||
|
||||
# Set to your IPv6 Interface Name
|
||||
dev=eth0
|
||||
|
||||
# One IP Check service returns just the ip; the other appends "Current IP Address:" we need to filter
|
||||
v4=$(curl -s http://freemyip.com/checkip)
|
||||
# v4=$(curl -s http://checkip.dyndns.org/ | awk -F '[:<>]' '/Current IP Address/{sub(/^[[:space:]]+/, "", $14); print $14}')
|
||||
# v4=$(curl -s http://192.168.1.1/getv4.php) # This uses my scripts on pfSense
|
||||
|
||||
# Pull IPv6 from interface - Pulls first non-local v6 from specified device
|
||||
v6=$(/sbin/ip -6 addr show dev $dev | awk '/inet6/ && !/fe80|::1/ {print $2}' | cut -f1 -d'/')
|
||||
|
||||
# Commands for curl
|
||||
curl="curl -s -S -q -f https://dyn.dns.he.net/nic/update -d hostname=$hostname -d password=$APIkey"
|
||||
v4cmd="-d myip=$v4"
|
||||
v6cmd="-d myip=$v6"
|
||||
|
||||
# Puts current DNS records in to variable
|
||||
loadips(){
|
||||
A=$1
|
||||
AAAA=$2
|
||||
}
|
||||
|
||||
loadips $(nslookup $hostname | awk '/^Address: / { print $2 }') # Gets current A and AAA recoreds
|
||||
[[ $v4 != $A ]] && $curl $v4cmd && echo "v4 Updated" # Update if different
|
||||
[[ $v6 != $AAAA ]] && $curl $v6cmd && echo "v6 Updated" # Update if different
|
Loading…
Reference in New Issue