1
0

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 3 years have passed since last update.

IBM Cloud DNS Services を VPC からプライベートな名前解決に使う

Last updated at Posted at 2020-06-10

#概要
こちらの続きです。
IBM Cloud の VPC と VPC と Classic Infrastructure を Transit Gateway で接続する - Qiita

こちらの構成を検証します。

Resolving DNS names with DNS Services
Resolving DNS names with DNS Services

#IBM Cloud DNS Services

CLI プラグインインストール


ibmcloud plugin install cloud-dns-services
ibmcloud plugin show cloud-dns-services

リソースグループ設定


ibmcloud target -g khayama

##サービスインスタンス作成


ibmcloud dns instance-create khayama-dns standard-dns
ibmcloud dns instance-target khayama-dns

##ゾーン作成


export zoneid=`ibmcloud dns zone-create ibmcloud.local --output json | jq -r .id`

##レコード作成


ibmcloud dns resource-record-create $zoneid --type A --name khayama-vsi1 --ipv4 192.168.10.10
ibmcloud dns resource-record-create $zoneid --type A --name khayama-vsi2 --ipv4 192.168.20.20

VPC からのアクセスを許可


export crn1=`ibmcloud is vpcs --json | jq -r '.[] | select (.name=="khayama-vpc-1") | .crn'`
export crn2=`ibmcloud is vpcs --json | jq -r '.[] | select (.name=="khayama-vpc-2") | .crn'`

ibmcloud dns permitted-network-add $zoneid --type vpc --vpc-crn $crn1
ibmcloud dns permitted-network-add $zoneid --type vpc --vpc-crn $crn2

VPC VSI の設定

こちらのドキュメントを参考に設定します。

Updating the DNS resolver for your VSI

デフォルトは「Public DNS Resolver」が以下のように設定されます。


[root@khayama-vsi1 ~]# cat /etc/resolv.conf 
; generated by /usr/sbin/dhclient-script
nameserver 161.26.0.10
nameserver 161.26.0.11

DHCP で DNS サーバーが上書きされないように
「IBM Cloud DNS Services」をプライベートな名前解決に使う設定をおこないます。(CentOS 7.x)


cat <<EOF > /etc/dhcp/dhclient.conf
supersede domain-name-servers 161.26.0.7, 161.26.0.8;
supersede domain-search "ibmcloud.local";
EOF

DHCP をリロードします。


dhclient -v -r eth0; dhclient -v eth0

DNS 設定が反映されたことを確認します。


[root@khayama-vsi1 ~]# cat /etc/resolv.conf 
; generated by /usr/sbin/dhclient-script
search ibmcloud.local.
nameserver 161.26.0.7
nameserver 161.26.0.8

名前解決の確認

以下のように確認できます。


[root@khayama-vsi1 ~]# ping google.com -c 4
PING google.com (172.217.17.142) 56(84) bytes of data.
64 bytes from ams15s30-in-f14.1e100.net (172.217.17.142): icmp_seq=1 ttl=55 time=14.1 ms
64 bytes from ams15s30-in-f14.1e100.net (172.217.17.142): icmp_seq=2 ttl=55 time=14.2 ms
64 bytes from ams15s30-in-f14.1e100.net (172.217.17.142): icmp_seq=3 ttl=55 time=14.3 ms
64 bytes from ams15s30-in-f14.1e100.net (172.217.17.142): icmp_seq=4 ttl=55 time=14.3 ms

--- google.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 14.133/14.241/14.303/0.109 ms

[root@khayama-vsi1 ~]# ping khayama-vsi2 -c 4
PING khayama-vsi2.ibmcloud.local (192.168.20.20) 56(84) bytes of data.
64 bytes from 192.168.20.20 (192.168.20.20): icmp_seq=1 ttl=55 time=1.38 ms
64 bytes from 192.168.20.20 (192.168.20.20): icmp_seq=2 ttl=55 time=1.52 ms
64 bytes from 192.168.20.20 (192.168.20.20): icmp_seq=3 ttl=55 time=1.36 ms
64 bytes from 192.168.20.20 (192.168.20.20): icmp_seq=4 ttl=55 time=1.40 ms

--- khayama-vsi2.ibmcloud.local ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 1.369/1.419/1.521/0.071 ms

[root@khayama-vsi2 ~]# ping khayama-vsi1 -c 4
PING khayama-vsi1.ibmcloud.local (192.168.10.10) 56(84) bytes of data.
64 bytes from 192.168.10.10 (192.168.10.10): icmp_seq=1 ttl=55 time=1.42 ms
64 bytes from 192.168.10.10 (192.168.10.10): icmp_seq=2 ttl=55 time=1.38 ms
64 bytes from 192.168.10.10 (192.168.10.10): icmp_seq=3 ttl=55 time=1.23 ms
64 bytes from 192.168.10.10 (192.168.10.10): icmp_seq=4 ttl=55 time=1.36 ms

--- khayama-vsi1.ibmcloud.local ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 1.239/1.353/1.421/0.073 ms

参考

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?