Raspberry PiでMyDNSにip通知をした時のメモ

更新:2019/12/10
はじめに
無料のDDNSであるMyDNSでの、ipアドレス通知をRaspberry Piで自動通知させた時のメモ書きです。



やってみる
// 適当なディレクトリでスクリプトを組む
// 今回はユーザーディレクトリ直下(/home/pi)に作成
$ nano MyDNS.sh

// MyDNS.shに以下のスクリプトを破線内のように入力する
// ユーザー名とパスワードにはMyDNSに登録したときに通知されたユーザー名とパスワードを入力してください
// もし「wget」が入っていな場合は、「sudo apt install wget」でインストールしてください
-----------------------------------------------------------------------
wget -O - --http-user=<ユーザー名(MasterID)> --http-password=<パスワード> http://www.mydns.jp/login.html
-----------------------------------------------------------------------

// 上のスクリプトが入力出来たら
// そのスクリプトに実行権限を設定する
$ chmod 755 MyDNS.sh

// crontabにスクリプトを破線内のように登録する
$ crontab -e

// 今回は毎時間0分になったら実行するように設定しました
-----------------------------------------------------------------------
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command

0 * * * * /home/pi/MyDNS.sh
-----------------------------------------------------------------------

おわりに
今回はRaspberry PiでMyDNSへのip通知を自動通知した時のメモ書きでした。

関連記事