1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AnsibleでWindowsのDNSの逆引きレコードを追加したときの話

Posted at

概要

WindowsのDNS逆引きレコードを追加しようとしたら、変なレコードが出来上がった話です。

環境

Ansible環境:CentOS7.6+Ansible2.8.5
ターゲット:Windows2016
ネットワーク:192.168.0.0/16

背景

ドメインコントローラで、Windows2016 ServerCoreを利用していたので、Ansibleでレコード登録をやろうと思いました。
AnsibleのDocumentを探していたら、「win_dns_record」なるものを発見。
逆引き登録がOKそうなので、試してみることにしました。

何が起きた?

正引きは、特に問題なくAレコードを作成できたので、今回は割愛します。

問題は逆引きです。
まず、レコード登録するZoneは存在している必要があります。
(無ければ事前に作成が必要です。今回は設定情報を明確にするため、サブネットは/16にしています。)

次に下記のようなPlaybookを作成しました。

dns_record.yml
name: Create PTR Record
win_dns_record:
  name: "192.168.1.100"
  state: present
  type: "PTR"
  value: "foo.hoge.com"
  zone: "168.192.in-addr.arpa"

登録されたレコードは下記の通りでした。

192.168.1.100.1.168.192 Pointer (PTR) foo.hoge.com

???
Bugだ!と思ってGitHubみたら、すでにCloseされていました・・・
win_dns_record incorrectly creates PTR records
Playbookは、下記のように修正すれば、正しく登録されました。

dns_record.yml
name: Create PTR Record
win_dns_record:
- name: "192.168.1.100"
+ name: "100.1"          #"1.100"ではないです
  state: present
  type: "PTR"
  value: "foo.hoge.com"
  zone: "168.192.in-addr.arpa"
192.168.1.100 Pointer (PTR) foo.hoge.com

公式サイトに凡例を追記するっぽいですね。
IPアドレスをひっくり返すのがポイントかと思います。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?