LoginSignup
6
2

More than 3 years have passed since last update.

OCI Compute OS再起動せずにDHCPオプションの設定を再反映させる

Last updated at Posted at 2020-03-05

はじめに

Oracle Cloud InfrastructureのVCN(仮想ネットワーク)内では、AWS VNC同様にDHCPでOSにIPアドレスとDHCPオプション(DNSサーバや検索ドメイン(DNSサフィックス))が配布されます。

この設定をOSを再起動することなく、再反映させるのが目的です。

やること

デフォルトのDHCPオプション設定は「Internet and VCN Resolver」という設定で、OCI VCNの内部DNS 169.254.169.254 を参照し、
検索ドメインとして「 [VCN DNS label].oraclevcn.com)」 が設定されています。

デフォルトでは、VCN内の名前解決と、外向けインターネットに名前解決ができる状態ですが、企業内部のDNSサーバを参照するように「Custom Resolver」に変更して、DNSサーバのIPアドレスを指定し、検索ドメインを「sample.local」に変更します。

前提

  • OCI VCN作成済み
  • OCI Compute OS作成済み(Oracle Linux 7.7とWindows 2016)

OCI DHCPオプションの変更

  • OCI VCN設定を開き、DHCPオプションの下記あたりを押下して、「編集」
    image.png

  • 「カスタムリゾルバ」に変更し、任意のDNSサーバIPと、検索ドメインを入力

  • 変更の保存

  • (余談)DNSサーバの指定は3つまで。検索ドメインは上限1つのみ・・!
    image.png

  • 変更された
    image.png

Oracle Linux 7.7でのDHCPオプションの反映

  • OSにログインをrootユーザに切り替え
  • 現在の設定を確認
$ sudo -i

# cat /etc/resolv.conf 
; Any changes made to this file will be overwritten whenever the
; DHCP lease is renewed. To persist changes you must update the
; /etc/oci-hostname.conf file. For more information see
;[https://docs.cloud.oracle.com/iaas/Content/Network/Tasks/managingDHCP.htm#notes]
;
; generated by /usr/sbin/dhclient-script
search vcntokyo1.oraclevcn.com subdmz.vcntokyo1.oraclevcn.com ★ここが変わる
nameserver 169.254.169.254 ★ここが変わる
  • dhclientコマンドを実行してDHCPオプションを反映
  • コマンド実行して返ってくるまで10秒くらいかかる
  • 設定を確認
# dhclient

# cat /etc/resolv.conf 
; Any changes made to this file will be overwritten whenever the
; DHCP lease is renewed. To persist changes you must update the
; /etc/oci-hostname.conf file. For more information see
;[https://docs.cloud.oracle.com/iaas/Content/Network/Tasks/managingDHCP.htm#notes]
;
; generated by /usr/sbin/dhclient-script
search sample.local ★変わった
nameserver 192.168.250.250 ★変わった
  • dhclientプロセスは残るのでKILL
# ps ax |grep dhc
 1574 ?        Ss     0:00 /sbin/dhclient -1 -q -lf /var/lib/dhclient/dhclient-ad083c0c-3c81-XXXX-9d74-XXXXXXX-ens3.lease -pf /var/run/dhclient-ens3.pid -H bastion ens3
 3868 ?        Ss     0:00 dhclient
 3914 pts/0    S+     0:00 grep --color=auto dhc

# kill 3868

Windows Server 2016でのDHCPオプションの反映

  • 現在の設定確認(長いので一部割愛)
C:\Users\opc>ipconfig /all

Windows IP Configuration

   Host Name . . . . . . . . . . . . : win1
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : vcntokyo1.oraclevcn.com ★ここが変わる

Ethernet adapter Ethernet:

   Connection-specific DNS Suffix  . : vcntokyo1.oraclevcn.com ★ここが変わる
   Description . . . . . . . . . . . : Broadcom NetXtreme-E Virtual Function
   Physical Address. . . . . . . . . : 02-00-17-00-1D-F7
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::1179:560f:c64f%2(Preferred)
   IPv4 Address. . . . . . . . . . . : 10.1.0.37(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : Thursday, March 5, 2020 9:56:51 PM
   Lease Expires . . . . . . . . . . : Friday, March 6, 2020 9:56:51 PM
   Default Gateway . . . . . . . . . : 10.1.0.1
   DHCP Server . . . . . . . . . . . : 169.254.169.254
   DHCPv6 IAID . . . . . . . . . . . : 33685527
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-25-EE-DA-EC-02-00-17-00-1D-F7
   DNS Servers . . . . . . . . . . . : 169.254.169.254 ★ここが変わる
   NetBIOS over Tcpip. . . . . . . . : Disabled
  • ipconfig /renew してDHCPオプションを反映
  • 設定を確認
C:\Users\opc>ipconfig /renew

C:\Users\opc>ipconfig /all

Windows IP Configuration

   Host Name . . . . . . . . . . . . : win1
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : sample.local ★変わった

Ethernet adapter Ethernet:

   Connection-specific DNS Suffix  . : sample.local ★変わった
   Description . . . . . . . . . . . : Broadcom NetXtreme-E Virtual Function
   Physical Address. . . . . . . . . : 02-00-17-00-1D-F7
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::1179:560f:c64f%2(Preferred)
   IPv4 Address. . . . . . . . . . . : 10.1.0.37(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : Thursday, March 5, 2020 9:56:51 PM
   Lease Expires . . . . . . . . . . : Friday, March 6, 2020 10:17:52 PM
   Default Gateway . . . . . . . . . : 10.1.0.1
   DHCP Server . . . . . . . . . . . : 169.254.169.254
   DHCPv6 IAID . . . . . . . . . . . : 33685527
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-25-EE-DA-EC-02-00-17-00-1D-F7
   DNS Servers . . . . . . . . . . . : 192.168.250.250 ★変わった
   NetBIOS over Tcpip. . . . . . . . : Disabled

参考

6
2
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
6
2