gtwy / IPv6forDuckDNS

Script to submit both IPv6 and IPv4 addresses to DuckDNS
GNU General Public License v3.0
63 stars 15 forks source link

IPv6 not updating #5

Closed FernandoMarques-Santos closed 3 years ago

FernandoMarques-Santos commented 3 years ago

I am using Ubuntu server 20.04 and using IPv6 for hosting a webpage locally (as my ISP uses the same IPv4 for multiple customers). Everything works fine until my IP changes again - the script does not seem to work in CRON, and the duckdns website does not update my IP

When I check the crontab (I actually changed the ~/ to the full path, same result)

~$ sudo crontab -e

There you can find:

/5 * home/myuser/duckdns6.sh >/dev/null 2>&1

And checking cron log file:

~$ sudo grep -i cron /var/log/syslog

You can see the cron is indeed running

Jul 7 12:40:01 mypcname CRON[23864]: (root) CMD (home/myuser/duckdns6.sh >/dev/null 2>&1) Jul 7 12:45:01 mypcname CRON[23875]: (root) CMD (home/myuser/duckdns6.sh >/dev/null 2>&1) Jul 7 12:50:01 mypcname CRON[24020]: (root) CMD (home/myuser/duckdns6.sh >/dev/null 2>&1)

Further details: I am using google to login in duckdns and token. I also checked the permissions to run the file:

~$ la -l

Where you can find:

-rw-rw-r-- 1 myuser myuser 177 Jul 3 01:51 .duck6.conf -rwxrwxrwx 1 root root 3203 Jul 3 01:48 autoconf-duckdns6.sh -rwxrwxr-x 1 myuser myuser 3203 Jul 3 01:51 duckdns6.sh

But when I run the script manually it all goes ok and online again

myuser@myserver:~$ sudo ./duckdns6.sh Your IPv4 has been detected as xxx.x.xx.xx [my actual ip4 here] Now connecting to DuckDNS and publishing your IPv6 2804:xxxx [my actual ip6 here] For domain myserver.duckdns.org with token [my token here]. OK

Then I see the duckdns successfully updated, and my website can be accessed by the name again. What gives?

gtwy commented 3 years ago

The script doesn't need to be run as root. I would just run it as a regular user. In fact, I would delete the config, the cron job, checking both user cron and the root cron to be sure. Then I would clone and run the script again from the start as a regular user.

Once that's done, you will want to start logging the cron job instead of outputting it into /dev/null so that we could see what was happening.

Are you using the most recent version of the script? I added more verbose logging in the latest version. Cloning the repo should fix that issue if you are using an old copy.

FernandoMarques-Santos commented 3 years ago

Thanks James, not sure what was wrong, but now it seems fixed. I will detail my (baby) steps here so anyone can do the same.

I started by deleting all the script and config files.

rm autoconf-duckdns6.sh duckdns6.sh .duck6.conf

Then I removed the duckdns cronjobs checking both:

sudo crontab -e crontab -e

Next, I downloaded the updated script to my home folder:

wget https://raw.githubusercontent.com/gtwy/IPv6forDuckDNS/master/autoconf-duckdns6.sh

Added the permission to execute the script by the user

sudo chmod u+x autoconf-duckdns6.sh

Ran the script using ./

./autoconf-duckdns6.sh

The script will ask for domain and token as usual. IPv4 it will find automatically, so just press enter

Check if the crontab is enabled to the user (if using nano, crt+x to close)

crontab -e

After five minutes, check if the crontab is actually running:

grep -i duckdns /var/log/syslog

If your IPv4 and IPv6 are already correct in duckdns (let's say that you updated it manually just so you can use the thing as is), you can't really see if the IPv6forDuckDNS script is working, because it will report "OK" regardless if any modification occurred. So I went to duckdns site and changed both my IPs (changed a random number and refreshed). Go get a coffee and wait 5 minutes for cron to refresh the duckdns. See if it is refreshed on the duck's website.

I had to wait for a couple of moments more (30s) to see if my site could be accessed again.

Extra step: As James pointed out, you can edit the cronjob to output something instead of being discarded by dev/null