- Registriert
- 18. Jan. 2017
- Beiträge
- 24
- Reaktionspunkte
- 1
- Punkte
- 9
Zuletzt bearbeitet:
#!/bin/bash
# Get public ipv6 address
ip=$(ip -6 addr list scope global $device | grep -v " fd" | sed -n 's/.*inet6 \([0-9a-f:]\+\).*/\1/p' | head -n 1)
USER=XXXXXX
PASSWORD=XXXXXX
URL=my.domain.com
# Exiting if ip address is empty
if [ -z $ip ];then
echo "IP address is empty. Exiting!"
exit 1
fi
# Exiting if ip address is unchanged
if [ $(cat address.txt) == "$ip" ];then
echo "IP address is unchanged. Ending."
exit 0
fi
#Make request to dns provider and set new ipv6
RESPONSE=$(curl "https://$URL:$PASSWORD@dyn.dns.he.net/nic/update?hostname=$URL&myip=$ip")
#echo $RESPONSE
# Return with code 0 if everything is ok and everything is ok, if ip address is in response
if [[ $RESPONSE =~ $ip ]];then
echo "Finished. Everything is ok."
#save ip address to address.txt to prevent updates on unchanged ip
echo $ip > address.txt
exit 0
else
echo "Finished with errors!"
exit 1
fi
#!/bin/bash
USER=XXXXXX
PASSWORD=XXXXXX
URL=my.domain.com
DEVICE=bond0
# Get public ipv6 address
ip=$(ip -6 addr list $DEVICE scope global | grep -v " fd" | sed -n 's/.*inet6 \([0-9a-f:]\+\).*/\1/p' | head -n 1)
# Exiting if ip address is empty
if [ -z $ip ];then
echo "IP address is empty. Exiting!"
exit 1
fi
# Exiting if ip address is unchanged
if [ $(cat address.txt) == "$ip" ];then
echo "IP address is unchanged. Ending."
exit 0
fi
#Make request to dns provider and set new ipv6
RESPONSE=$(curl "https://$URL:$PASSWORD@dyn.dns.he.net/nic/update?hostname=$URL&myip=$ip")
#echo $RESPONSE
# Return with code 0 if everything is ok and everything is ok, if ip address is in response
if [[ $RESPONSE =~ $ip ]];then
echo "Finished. Everything is ok."
#save ip address to address.txt to prevent updates on unchanged ip
echo $ip > address.txt
exit 0
else
echo "Finished with errors!"
exit 1
fi
Bash:#Make request to dns provider and set new ipv6 RESPONSE=$(curl "https://$URL:$PASSWORD@dyn.dns.he.net/nic/update?hostname=$URL&myip=$ip")
Wenn du das Forum hilfreich findest oder uns unterstützen möchtest, dann gib uns doch einfach einen Kaffee aus.
Als Dankeschön schalten wir deinen Account werbefrei.