LoginSignup
1
0

Azure DNS のワイルドカードレコードを試してみた

Posted at

Apache や Nginx で SNI を使って FQDN ごとコンテンツを出し分けたり、リバースプロキシ用途で SNI ごとにそれぞれのバックエンドサーバーに転送したりしています。例えば SaaS アプリを提供する側として、サブドメインを顧客領域として提供する場合、毎回サブドメインを追加するのは面倒なので、今回試してみた Azure DNS のワイルドカードレコードを使って楽をしようと思います。

例えば Google DNS の 正引き

bash
$ host dns.google
dns.google has address 8.8.8.8
dns.google has address 8.8.4.4
dns.google has IPv6 address 2001:4860:4860::8844
dns.google has IPv6 address 2001:4860:4860::8888

Google DNS に Ping を試す

bash
$ ping -c 4 dns.google
PING dns.google (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=116 time=9.174 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=116 time=15.317 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=116 time=16.383 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=116 time=13.862 ms

--- dns.google ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 9.174/13.684/16.383/2.753 ms

Azure DNS に CNAME でワイルドカードレコードを登録

bash
$ az network dns record-set cname set-record \
  --resource-group mnrlabo-rg \
  --zone-name mnrsdev.com \
  --record-set-name "*.ex" \
  --cname dns.google

Azure ポータルでワイルドカードレコードを確認

azure-dns-wildcard-01.png

例えば aaa というサブドメインの場合

bash
$ host aaa.ex.mnrsdev.com
aaa.ex.mnrsdev.com is an alias for dns.google.
dns.google has address 8.8.8.8
dns.google has address 8.8.4.4
dns.google has IPv6 address 2001:4860:4860::8844
dns.google has IPv6 address 2001:4860:4860::8888

$ ping -c 4 aaa.ex.mnrsdev.com
PING dns.google (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=116 time=9.542 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=116 time=15.680 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=116 time=7.332 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=116 time=12.921 ms

--- dns.google ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 7.332/11.369/15.680/3.187 ms

例えば bbb というサブドメインの場合

bash
$ host bbb.ex.mnrsdev.com
bbb.ex.mnrsdev.com is an alias for dns.google.
dns.google has address 8.8.4.4
dns.google has address 8.8.8.8
dns.google has IPv6 address 2001:4860:4860::8844
dns.google has IPv6 address 2001:4860:4860::8888

$ ping -c 4 bbb.ex.mnrsdev.com
PING dns.google (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=116 time=7.245 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=116 time=7.194 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=116 time=7.896 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=116 time=15.948 ms

--- dns.google ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 7.194/9.571/15.948/3.692 ms

後片付け

bash
$ az network dns record-set cname remove-record \
  --resource-group mnrlabo-rg \
  --zone-name mnrsdev.com \
  --record-set-name "*.ex" \
  --cname dns.google

参考

1
0
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
0