Ubuntu ServerでダイナミックDNSフェッチサービスを設定するにはどうすればよいですか?


19

http://no-ip.org/アカウント内にアカウントとホスト名を作成しました。これは、私のタイプのサーバーで最も一般的に使用されるサービスです。私はコマンドラインnoobであるため、no-ipでddclientを使用する構成プロセスを誰かに教えてもらえますか?

回答:


21

No-IP用のddclientのセットアップ

ddclientは、動的DNSエントリを更新するために使用できる動的更新クライアント(DUC)です。現在のIPアドレスを定期的にチェックし、変更が検出されるとDNS情報を更新します。以下は、No-IP(noip.com/no-ip.com)サービス用にインストールおよび構成する方法です。

まず、ddclientパッケージをインストールします。後で手動で設定するため、設定に関するすべての質問に対してEnterキーを押します。

sudo apt-get install ddclient

ddclientデーモンを停止します。このsudo service ddclient stopコマンドは、バグが原因でUbuntu 12.04で機能しないため、pkill代わりに使用します。

sudo pkill ddclient

構成ファイルを編集します。デフォルト/etc/ddclient.conf~gedit作成され、たとえば削除したと思われる後にパスワードを含めることができるバックアップファイル(例:)をオフにするには、設定をオフにします Edit -> Preferences -> Editor -> Create a backup copy of files before saving

sudo gedit /etc/ddclient.conf /etc/default/ddclient

/etc/ddclient.conf以下のテンプレートの古いコンテンツを削除して貼り付けます。

テンプレートのコメントを読み、必要に応じてファイルをカスタマイズします。

noip.comサブアカウント、つまりパスワードを持つグループ(この機能は有料サービスです)を使用することをお勧めします。この方法では、パスワードは指定されたホストの更新のみにアクセスでき、MXレコードを含む可能性のあるNo-IPアカウント全体へのフルアクセスではありません(パスワードを取得する攻撃者は、電子メールを傍受するためにMXレコードを変更できます)またはIMAPアカウントなどの他のサービス。

おそらく設定する必要がありますdaemon_interval=3600(テンプレートのコメントを参照)。

次のコマンドで構成をテストします。

sudo ddclient -daemon=0 -debug -verbose -noquiet -force

good(IPアドレスが更新された)またはnochg(IPアドレスが既にその値に設定されていた)応答を受け取る必要があります。この時点で次の警告を受け取っても構いません(ただし、通常の操作中に警告を受け取り続けることはできません)。

WARNING: updating <hostname>: nochg: No update required; unnecessary attempts to change to the current address are considered abusive

注:No-IPサーバーでキャッシュが行われているようです。そのため、サーバーからの応答が期待したものと異なる場合は、しばらく待つだけで済む場合があります。

設定が完了したら、ddclientデーモンを起動します。

sudo service ddclient start

また、デーモンはコンピューターを起動するたびに自動的に起動します。

DNSエントリは、IPアドレスの変更が検出されるたびに更新されるようになりました。

トラブルシューティング

パッケージ構成を再度実行します。

sudo dpkg-reconfigure ddclient

Remove package and config files:

sudo apt-get purge ddclient

Daemon control:

sudo service ddclient status
sudo service ddclient start
sudo service ddclient stop
# The stop command above does not work on Ubuntu 12.04 due to a bug, but
# it works on 14.04. Here are alternative ways to control the daemon:
ps -A f | grep -i ddclient
sudo pkill ddclient

Delete the cache to trick the daemon into updating the DNS entry for debugging purposes (during normal operation the DNS entry is only updated if the current IP address is different from the IP address stored in the cache):

sudo pkill ddclient
sudo rm /var/cache/ddclient/ddclient.cache
sudo service ddclient start
# See the result:
tail /var/log/syslog
# If you have set up mail=..., you should also receive an e-mail.
# The syslog and e-mail should show a "good" or "nochg" response.

Test whether the daemon will actually update the DNS entry when the IP address has changed, by setting the DNS entry IP address to 1.2.3.4 and then starting the daemon:

sudo pkill ddclient
sudo ddclient -daemon=0 -debug -verbose -noquiet -force -use ip -ip 1.2.3.4
sleep 30   # ddclient will not perform updates less than 30 seconds apart
sudo service ddclient start

Debug run (update DNS entry never / as needed / always):

sudo ddclient -daemon=0 -debug -verbose -noquiet -noexec
sudo ddclient -daemon=0 -debug -verbose -noquiet
sudo ddclient -daemon=0 -debug -verbose -noquiet -force

Try to detect current IP address using various methods:

sudo ddclient -query

Files of interest:

/etc/ddclient.conf
/etc/default/ddclient
/var/cache/ddclient/ddclient.cache

Messages from the daemon will appear here (and will also be sent by e-mail if set up to do so):

/var/log/syslog

Documentation:

Template for /etc/ddclient.conf

################################################################################
# Configuration file for ddclient
################################################################################


################################################################################
# Misc. configurations

# To choose between ipup mode (for dial-on-demand) and daemon mode, please edit
# /etc/default/ddclient.

#mail=root           # E-mail messages to this address
#mail-failure=root   # E-mail messages about failed updates to this address


################################################################################
# How to obtain current IP address

# Methods:
#   use=ip, ip=ADDRESS                                   # Set the IP address to ADDRESS
#   use=if, if=INTERFACE, if-skip=PATTERN                # Obtain IP address by calling 'ifconfig INTERFACE'
#   use=web, web=PROVIDER|URL, web-skip=PATTERN          # Obtain IP address from IP discovery web page
#   use=cmd, cmd=PROGRAM, cmd-skip=PATTERN               # Obtain IP address by calling PROGRAM
#   use=fw|FWMODEL, fw=ADDRESS|URL, fw-skip=PATTERN      # Obtain IP address from firewall web page
#                   fw-login=LOGIN, fw-password=SECRET
#
# The *-skip options can be used to skip IP addresses found before PATTERN.
#
# NOTE: The ddclient IP detection routines do not respect the HTTPS prefix in
# URLs, and instead fall back to HTTP (this is fixed in version 3.8.1). The
# option ssl=yes does not apply to the IP detection either (this is at least
# how versions 3.8.0 to 3.8.2 behave).
#
# The default time between each IP address change check is daemon_interval=300
# (5 minutes), which may be a bit too frequent when using an external IP
# discovery service. To set the checking interval to e.g. one hour instead,
# please edit /etc/default/ddclient and set daemon_interval=3600.

# Obtain IP address from network interface
#use=if, if=eth0

# Obtain IP address from no-ip.com IP discovery web page (unencrypted connection)
use=web, web='http://ip1.dynupdate.no-ip.com:8245/'

# Obtain IP address from no-ip.com IP discovery web page (encrypted connection)
# Encryption does not offer any real protection since a man-in-the-middle
# attack could route the HTTPS connection through a host belonging to the
# attacker, thus causing an incorrect IP address to be reported.
#use=cmd, cmd='bash -c "set -o pipefail; timeout 120 wget -qO- \
#  --header=Host:ip1.dynupdate.no-ip.com https://dynupdate.no-ip.com/ | head -c 1000"'


################################################################################
# Dynamic DNS service setup

protocol=noip
#server=   # Defaults to dynupdate.no-ip.com for noip protocol
ssl=yes   # NOTE: Does not apply when obtaining IP address, just when updating the DNS entry!
login='nobody@nowhere.com'   # Username. For No-IP sub-accounts (groups with passwords), use '<groupname>%3A<username>'.
password='1234'


################################################################################
# Hosts to update, with optional per-host options

# Examples:
#   protocol=hammernode1, \
#   login='my-hn-login', password='my-hn-password' \
#   myhost.hn.org,myhost2.hn.org
#
#   login='group2%3Ajohndoe@domain.com', password='1234'   myhost3.no-ip.biz,myhost4.no-ip.biz
#
#   myhost.no-ip.biz,myhost2.no-ip.biz

my.full.hostname

Update: Encrypted connection to IP detection service is quite pointless. This is now explained in the ddclient.conf template and it now defaults to using unencrypted connection for IP detection.



0

No-ip has its own client which worked for me first time it was installed.

There are instructions on their own website to download the client, and then it's a quick make && make install and you're done. Have your login credentials for no-ip to hand as you will be asked them as part of the configuration wizard. Afterwards, make sure you run noip2 and you can check your host account on their site to see if it has updated.


WARNING: noip2 has security issues! See this answer.
Håkon A. Hjortland

@HåkonA.Hjortland: I didn't realize it accepts HTTPS connections. I've deleted my previous incorrect statement, thanks!
MestreLion
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.