0x00 TL;DR Usually, after the DHCP Options Set changes, it takes several hours for the EC2 instance inside the VPC to use the new DHCP Options Set. This article describes how to make the configuration of the DHCP Options Set take effect immediately in the specified EC2 instance. The overall idea is to restart the EC2 instance network and let the DHCP service reassign network information.
0x01 VPC change DHCP Options Set 1 aws ec2 associate-dhcp-options --dhcp-options-id dopt-06d6a444d7a288888 --vpc-id vpc-0614eddfdb8988888
Note:After you associate a new set of DHCP options with a VPC, any existing instances and all new instances that you launch in the VPC use these options. You don’t need to restart or relaunch the instances. They automatically pick up the changes within a few hours, depending on how frequently the instance renews its DHCP lease. If you want, you can explicitly renew the lease using the operating system on the instance.
Windows Server 2016 Renew DHCP Lease(ipconfig /renew):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 C:\Users\Administrator>ipconfig Windows IP 配置 以太网适配器 以太网: 连接特定的 DNS 后缀 . . . . . . . : cn-north-1.compute.internal 本地链接 IPv6 地址. . . . . . . . : fe80::dd5d:2739:e78f:5566%14 IPv4 地址 . . . . . . . . . . . . : 10.0.0.39 子网掩码 . . . . . . . . . . . . : 255.255.255.0 默认网关. . . . . . . . . . . . . : 10.0.0.1 隧道适配器 isatap.cn-north-1.compute.internal: 媒体状态 . . . . . . . . . . . . : 媒体已断开连接 连接特定的 DNS 后缀 . . . . . . . : 隧道适配器 本地连接* 3: 连接特定的 DNS 后缀 . . . . . . . : IPv6 地址 . . . . . . . . . . . . : 2001:0:348b:fb58:4f6:3e50:f5ff:ffd8 本地链接 IPv6 地址. . . . . . . . : fe80::4f6:3e50:f5ff:ffd8%12 默认网关. . . . . . . . . . . . . : :: C:\Users\Administrator>ipconfig /renew Windows IP 配置 以太网适配器 以太网: 连接特定的 DNS 后缀 . . . . . . . : corp.tonghua.com 本地链接 IPv6 地址. . . . . . . . : fe80::dd5d:2739:e78f:5566%14 IPv4 地址 . . . . . . . . . . . . : 10.0.0.39 子网掩码 . . . . . . . . . . . . : 255.255.255.0 默认网关. . . . . . . . . . . . . : 10.0.0.1 隧道适配器 本地连接* 3: 媒体状态 . . . . . . . . . . . . : 媒体已断开连接 连接特定的 DNS 后缀 . . . . . . . : 隧道适配器 isatap.corp.tonghua.com: 媒体状态 . . . . . . . . . . . . : 媒体已断开连接 连接特定的 DNS 后缀 . . . . . . . : C:\Users\Administrator>
Amazon Linux 2 Renew DHCP Lease(sudo service network restart):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 [ec2-user@ip-10-0-0-64 ~]$ cat /var/lib/dhclient/dhclient--eth0.lease lease { interface "eth0"; fixed-address 10.0.0.64; option subnet-mask 255.255.255.0; option dhcp-lease-time 3600; option routers 10.0.0.1; option dhcp-message-type 5; option dhcp-server-identifier 10.0.0.1; option domain-name-servers 10.0.0.2; option interface-mtu 9001; option broadcast-address 10.0.0.255; option host-name "ip-10-0-0-64"; option domain-name "cn-north-1.compute.internal"; renew 4 2019/05/23 13:35:11; rebind 4 2019/05/23 14:02:11; expire 4 2019/05/23 14:09:41; } lease { interface "eth0"; fixed-address 10.0.0.64; option subnet-mask 255.255.255.0; option routers 10.0.0.1; option dhcp-lease-time 3600; option dhcp-message-type 5; option domain-name-servers 10.0.0.2; option dhcp-server-identifier 10.0.0.1; option interface-mtu 9001; option broadcast-address 10.0.0.255; option host-name "ip-10-0-0-64"; option domain-name "cn-north-1.compute.internal"; renew 4 2019/05/23 13:36:56; rebind 4 2019/05/23 14:02:23; expire 4 2019/05/23 14:09:53; } lease { interface "eth0"; fixed-address 10.0.0.64; option subnet-mask 255.255.255.0; option routers 10.0.0.1; option dhcp-lease-time 3600; option dhcp-message-type 5; option domain-name-servers 10.0.0.2; option dhcp-server-identifier 10.0.0.1; option interface-mtu 9001; option broadcast-address 10.0.0.255; option host-name "ip-10-0-0-64"; option domain-name "cn-north-1.compute.internal"; renew 4 2019/05/23 14:00:23; rebind 4 2019/05/23 14:29:26; expire 4 2019/05/23 14:36:56; } lease { interface "eth0"; fixed-address 10.0.0.64; option subnet-mask 255.255.255.0; option routers 10.0.0.1; option dhcp-lease-time 3600; option dhcp-message-type 5; option domain-name-servers 10.0.0.2; option dhcp-server-identifier 10.0.0.1; option interface-mtu 9001; option broadcast-address 10.0.0.255; option host-name "ip-10-0-0-64"; option domain-name "cn-north-1.compute.internal"; renew 4 2019/05/23 14:29:09; rebind 4 2019/05/23 14:52:53; expire 4 2019/05/23 15:00:23; } lease { interface "eth0"; fixed-address 10.0.0.64; option subnet-mask 255.255.255.0; option routers 10.0.0.1; option dhcp-lease-time 3600; option dhcp-message-type 5; option domain-name-servers 10.0.0.2; option dhcp-server-identifier 10.0.0.1; option interface-mtu 9001; option broadcast-address 10.0.0.255; option host-name "ip-10-0-0-64"; option domain-name "cn-north-1.compute.internal"; renew 4 2019/05/23 14:56:39; rebind 4 2019/05/23 15:21:39; expire 4 2019/05/23 15:29:09; } [ec2-user@ip-10-0-0-64 ~]$ sudo service network restart Restarting network (via systemctl): [ OK ] [ec2-user@ip-10-0-0-64 ~]$ cat /var/lib/dhclient/dhclient--eth0.lease lease { interface "eth0"; fixed-address 10.0.0.64; option subnet-mask 255.255.255.0; option dhcp-lease-time 3600; option routers 10.0.0.1; option dhcp-message-type 5; option dhcp-server-identifier 10.0.0.1; option domain-name-servers 10.0.0.2; option interface-mtu 9001; option broadcast-address 10.0.0.255; option host-name "ip-10-0-0-64"; option domain-name "cn-north-1.compute.internal"; renew 4 2019/05/23 14:56:39; rebind 4 2019/05/23 15:21:39; expire 4 2019/05/23 15:29:09; } lease { interface "eth0"; fixed-address 10.0.0.64; option subnet-mask 255.255.255.0; option routers 10.0.0.1; option dhcp-lease-time 3600; option dhcp-message-type 5; option domain-name-servers 10.0.1.101,10.0.3.86; option dhcp-server-identifier 10.0.0.1; option interface-mtu 9001; option broadcast-address 10.0.0.255; option host-name "ip-10-0-0-64"; option domain-name "corp.tonghua.com"; renew 4 2019/05/23 15:14:34; rebind 4 2019/05/23 15:39:02; expire 4 2019/05/23 15:46:32; } [ec2-user@ip-10-0-0-64 ~]$
0x03 Reference