#DDNS

1 messages · Page 1 of 1 (latest)

thin swan
#

Ok I can see that being extremely useful and definitely something for me to look into. I was gonna consider a backup option for when the dedicated TTS/STT stuff falls over

#

Though if it did fall over I'd probably tell HA to call me as I'd consider that a level 4 event

tribal tangle
#

whisper-dyndns.sh #!/bin/bash

List of IP addresses to ping

IP_STRING="192.168.5.80 10.209.212.9 192.168.5.5 192.168.5.1"
hostname="whisper.pwap"

Function to check if IP is reachable

check_ip_reachable() {
ip="$1"
ping -c 1 -W 1 "$ip" >/dev/null 2>&1
}

Main script

for ip in $IP_STRING; do
if check_ip_reachable "$ip"; then
echo "Found reachable IP: $ip"
/usr/local/bin/dyndnsmasq.sh "$ip" "$hostname"
exit 0
fi
done

echo "No reachable IP found in the list."

thin swan
#

So the way I'd do it is if it can reach the dedicated TTS STT server use that, else use built in one in HA

tribal tangle
#

cat /usr/local/bin/dyndnsmasq.sh
#!/bin/bash

Function to add or update a hostname in /etc/dyndnshosts

add_update_hostname() { ip="$1"
hostname="$2"
# Replace the old IP with the new one if the hostname exists if grep -q " $hostname$" /etc/dyndnshosts; then
sed -i "s/^[0-9.]* $hostname$/$ip $hostname/" /etc/dyndnshosts
else
echo "$ip $hostname" >> /etc/dyndnshosts
fi
}

Function to reload dnsmasq

reload_dnsmasq() {
systemctl reload dnsmasq
}

Main script

if [[ $# -ne 2 ]]; then
echo "Usage: $0 <ipv4> <hostname>"
exit 1 fi
ip="$1"
hostname="$2"
add_update_hostname "$ip" "$hostname"
reload_dnsmasq
echo "Hostname '$hostname' with IP '$ip' added/updated in /etc/dyndnshosts and dnsmasq reloaded."
root@doorman:~/bin#

thin swan
#

And if it goes down for more than say 30 minutes, HA initiates a call to me to tell me

tribal tangle
#

Eumm better put it in git.

#

Im on my phone right now

#

Well you use the ddns in home assistant

#

And the linux dns server has ever min a script running that sets the fastest ip to the dns

#

Cashing fixes ip changes in between transactions

thin swan
#

Will definitely look into this in the future after running more basic experimentation on HA (and after the more basic experimentation, I'll go and buy some hardware for it)

#

For the voice compute server I'm probably gonna run WiFi for it. Potentially run some other servers on there as well

tribal tangle
#

@thin swan I 1st had it with a online ddns service. but then i had a internet outage. Make sure your HA does not go to stone age mode if inet is down.

thin swan
#

Yeah, my plan is to allow the HA to keep ticking along if the internet goes down

#

But it obviously would not be able to fire a phone call to tell me. But when it came back up it would fire a notification that there was an outage from x to y time

tribal tangle
#

just use a uptime bot