Page 1 of 1

my pi's website stopped working

Posted: Mon Jul 20, 2015 4:58 pm
by Fght
when i run the duck dns './' to try to test it it says no such directory (linux cron installation)

what should i do? perhaps install the duck dns again? if yes what happened to it ?

Re: my pi's website stopped working

Posted: Mon Jul 20, 2015 7:07 pm
by Fght
where can i get help with lighttpd and duckdns?
i really want my site to return and i've tried the duck installment again already with no results

Re: my pi's website stopped working

Posted: Thu Aug 06, 2015 8:40 pm
by sixbacon
I have struggled a bit with setting up duckdns on the RPi, but got there in the end. Here’s what I did.

I wanted use a dns service to access IOT units in my house and wanted the RPi to talk to the duckdns server every five minutes to keep my domain on the duckdns pointing at the correct IP. The instructions on the duckdns site are a bit opaque to ordinary mortals and didn’t quite work for me.

I tried using sudo in front of the commands but it made no difference, so it is not necessary.

1. Create a script file on the Rpi to contact the duckdns site. Create a directory and then the file. Do this in your home directory, /home/pi, usually. Open a terminal window and type - mkdir duckdns, after the prompt, mine is [email protected] pi ~$

[email protected] pi ~$ mkdir duckdns

then go to that directory

[email protected] pi ~ $ cd duckdns

create the script file using nano , by typing - nano

[email protected] pi ~ /duckdns $ nano

Now you need the name of the domain you created when you signed up to duckdns say MYIOT and the long token, or security code you were issued with, something like

The script file will call the program curl, a command line tool that will send data or request data from a server, in this case The instruction curl is to use is piped to it using the echo command. You need to put in the path to your duckdns directory as it appears on your computer. On my machine this /home/pi. So enter precisely,

echo url=" ... 4a50f2&ip=" | curl -k -o /home/pi/duckdns/duck.log -K –

all in one line, replacing the domain name, the token and path with your values. Pay attention to the quotation marks, spaces, vertical line, the & symbols. The various parameters after the curl command are directives, google for details. A log file, duckdns.log, is created, which is overwritten each time (single >), with the results of the curl call. All it will contain is ”OK”, if it is successful. You can use leafpad to edit the script file and cut and paste from the duckdns web site if you find this easier.

(If like me you want to check it runs every five minutes for the first few days, add a second line to the script file

date >> /home/pi/duckdns/time.log

This will add to the time.log file each time the script runs, (>> ) with the date and time the script ran. This file will grow and grow, so delete the line from the script, once you are happy it is running.)

Close nano with CTRL X, y, Return.

2. Make the script an executable file, by typin g- chmod 700

[email protected] pi ~ /duckdns $ chmod 700

It is best to test the file works, type - ./

[email protected] pi ~ /duckdns $ ./

It should return something like

%Total % Received % Xfred Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2 0 2 0 0 0 --:--:-- 0:00:02 --:--:-- 1
[email protected] pi ~ /duckdns $

Then have a look at the log file, type cat duck.log

[email protected] pi ~ /duckdns $ cat duck.log
OK [email protected] pi ~ /duckdns $

Note the “OK” at the start of the line, the conents of the file. That shows it is working.

3. Set up program cron to run this script at 5 min intervals by editing the text file that drives cron by typing, crontab -e
[email protected] pi ~ /duckdns $ crontab -e

This will open a text editor and show the current contents with several lines of instructions with # to indicate comment lines. There may be data lines at the end of these, go to a the start of a blank line below everything and enter precisely

*/5 * * * * /home/pi/duckdns/ >/dev/null 2>&1

Again noting the spaces and replacing the path with the correct one for your machine. This tells cron to run the script ,, every 5 min and send the output and any error messages(2>&1) to a an empty file (null). I found I had to put in the full path to get it to work, unlike the instructions on, which used the path shortcut “~”.

Exit the editor using Ctrl X, y, Return. Assuming all is correct you should see,

[email protected] pi ~$ crontab –e
crontab: installing new crontab

To check it is working look at the date on the duck.log file, or delete the log file and see when it is created again. (If you added the date line to script file, look at the time.log file, using

[email protected] pi ~$ cat time.log

or viewing it in leafpad.)

Hopefully not to long winded, but I wanted to explain the steps so you can trace faults more easily.

Re: my pi's website stopped working

Posted: Thu Aug 06, 2015 8:55 pm
by DougieLawson
I think it's exceedingly long winded.

I run this

Code: Select all


OLDaddr=$(head -1 /home/pi/ipaddr.saved.txt)
IPaddr=$(printf '\42';dig +short \ | awk '{printf "%s",$0}';printf '\42')

if [ $IPaddr == '""' ]; then
  exit 20

if [ $OLDaddr != $IPaddr ]; then
  NOW=$(date +"%d/%m/%Y, %T,")
  printf "$NOW New address found\r\n"
  echo -e $NOW$IPaddr >> /home/pi/ipaddr.log.txt
  echo $IPaddr | tee /home/pi/ipaddr.saved.txt
  printf "\r\n"
  curl -s -o - --user dnsOmaticuserid:dnsOmaticpassword
  printf "\r\n"
  # NOT needed - done by DNS-O-Matic  ==>  curl -s -o - ",domain2&token=axxxae55-xaxx-xcxx-xxxx-fxxxxdb644af&ip="
  printf "\r\n"
every 5 mins from cron. does the update for everything including DuckDNS. It only gets called if the IP address returned from the DIG command has changed from last time. (Currently my address hasn't changed since 17th July.)

I also get a complete log of every address assigned and the date/time that happened and because I'm running it from cron, cron will also generate an email (which I can send out to gmail).