---
title: "CloudflareをDDNSみたいに使う"
id: "6819"
type: "post"
slug: "cloudflare%e3%82%92ddns%e3%81%bf%e3%81%9f%e3%81%84%e3%81%ab%e4%bd%bf%e3%81%86"
published_at: "2024-01-27T02:30:20+00:00"
modified_at: "2024-02-20T08:28:30+00:00"
url: "https://www.okin-jp.net/archives/6819"
markdown_url: "https://www.okin-jp.net/archives/6819.md"
excerpt: "MacのWindowsAppからxrdpにrdp接続するとusキーボードになってしまうので調査 Continue reading"
taxonomy_category:
  - "Server"
taxonomy_post_tag:
  - "ddclient"
  - "サーバー運用"
---

## やりたいこと

Cloudflareで動的グローバルIPアドレス環境のホストしたい！

## やりかた

### 前提

- Ubuntu 22.04.3 LTS
- ddclient 3.9.1以降
- Cloudflare

### 方針

[ddclient](https://ddclient.net/)
で定期的にIPアドレスの変化を確認して更新までを実施します。

変化したときだけCloudflareのアドレスを書き換えるので毎分チェックします。

### インストール

Ubuntu 22.04 LTSで標準リポジトリからダウンロードできるddclientは3.9系なので簡単です。

Shell

sudo apt-get install ddclient

| 1 | sudo apt-get install ddclient |
| --- | --- |

※Ubuntu 20.04の場合ddclientが3.8系で古いので、[ddclient package : Ubuntu (launchpad.net)](https://launchpad.net/ubuntu/+source/ddclient)
からダウンロードしてきましょう。

### コンフィグ

Ubuntuでは /etc/ddclient.conf がデフォルトの設定です。  
 サーバーのIPアドレスはプライベートIPアドレスなのでwebメソッドでチェックすることにしています。  
 webはHTTPでIPアドレスを返してくれれば良いのでコンフィグ例の[ip1.info](https://ip1.info)
 ではなく[ipify.org](https://www.ipify.org/)
や[myip.dnsomatic.com](https://myip.dnsomatic.com/)
を使うことも出来ます。  
 コンフィグを試すときは-vを付けるとエラーがわかりやすいです。

### 定期実行

いちばん簡単なのはcronを使うことです。

Shell

sudo crontab -e

| 1 | sudo crontab -e |
| --- | --- |

毎分実行するように設定します。

contabShell

* * * * * ddclient --file /etc/ddclient.conf

| 1 | * * * * * ddclient --file /etc/ddclient.conf |
| --- | --- |

## まとめ

簡単便利なddclientを使ってDDNSのアドレス更新をしましょう。

![おきん(blog)](https://secure.gravatar.com/avatar/90fa8845304183a491e9f3bfa0a6a44e46e25882407e4aa652815d725d55bd8c?s=100&r=g)

[おきん(blog)](https://www.okin-jp.net/archives/author/oops-okin)

[https://mi.okin-jp.net/@okin_p](https://mi.okin-jp.net/@okin_p)
(Misskey)  
 [https://fi.okin-jp.net/@okin_p](https://fi.okin-jp.net/@okin_p)
(Firefish)  
 [https://si.okin-jp.net/@okin_p](https://si.okin-jp.net/@okin_p)
(Mastodon)

[https://fedifile.net/@okin_p/profile/](https://fedifile.net/@okin_p/profile/)
  
 [https://twpf.jp/okin_p](https://twpf.jp/okin_p)
  
 [http://profile.hatena.ne.jp/okin_p/](http://profile.hatena.ne.jp/okin_p/)

名前：おきん  
 やってること：面倒なことをPHPにやらせる、IPv6でなにかする、車で移動する  
 主なガジェット：Google Pixel 4a (5G) ,iPhone XS(ジャンク), iPad mini5, その他

種別：IPv6 Single stack 猫

パソコンやガジェットについて書いていく…予定。

[https://twitter.com/okin_p](https://twitter.com/okin_p)
[https://si.okin-jp.net/@okin_p](https://si.okin-jp.net/@okin_p)

### *関連記事*

### コメントを残す[コメントをキャンセル](/archives/6819#respond)

このサイトはスパムを低減するために Akismet を使っています。[コメントデータの処理方法の詳細はこちらをご覧ください](https://akismet.com/privacy/)
。
