Amazon提供的DNS服务器IP地址可以在AWS控制台中查找。具体步骤如下:
修改VPC配置时,可以选择将新的选项集应用于整个VPC或特定的子网。以下是用Python代码来创建和更新DHCP选项集的例子:
创建DHCP选项集:
import boto3
client = boto3.client('ec2')
response = client.create_dhcp_options(
DhcpConfigurations=[
{
'Key': 'domain-name-servers',
'Values': ['AmazonProvidedDNS', '\"172.31.0.2\"']
}
]
)
print(response)
更新DHCP选项集:
import boto3
client = boto3.client('ec2')
response = client.create_dhcp_options(
DhcpConfigurations=[
{
'Key': 'domain-name-servers',
'Values': ['AmazonProvidedDNS', '\"172.31.0.2\"']
}
]
)
print(response)
dhcp_options_id = response['DhcpOptions']['DhcpOptionsId']
response = client.associate_dhcp_options(
DhcpOptionsId=dhcp_options_id,
VpcId='your_vpc_id'
)
print(response)
请注意,这些代码示例假定您已经正确配置了AWS凭据。