VPC DHCP Domain changes

0

I changed the domain name server in the AWS DHCP option set configuration. The changes (nameserver) do not show up in the DNS settings in EC2 servers under /etc/resolv.conf file. Any idea?

asked 2 months ago98 views
2 Answers
0

When you change the domain name server in the AWS DHCP option set configuration for a VPC, the changes may not immediately reflect in the /etc/resolv.conf file of existing EC2 instances. This is because the DHCP lease renewal process determines when instances pick up new options.

Typically, instances in the VPC will automatically pick up the new options within a few hours, depending on their DHCP lease renewal frequency. However, if you need the changes to take effect immediately, you have a few options:

  1. Reboot the EC2 instance. This will force the instance to obtain new DHCP options upon restart.

  2. If you can't reboot, you can manually update the /etc/resolv.conf file. However, be aware that this manual change may be overwritten on the next DHCP lease renewal or system reboot.

  3. For a more permanent solution that persists across reboots, you can override the DNS settings provided by the DHCP options. This can be done by modifying the DHCP client configuration file (/etc/dhcp/dhclient.conf) on your EC2 instance. Add a line like this:

    supersede domain-name-servers xxx.xxx.xxx.xxx;

    Replace xxx.xxx.xxx.xxx with the IP address of your desired DNS server.

  4. On newer systems using systemd-resolved, you might need to modify /etc/systemd/resolved.conf instead.

After making these changes, you may need to restart the networking service or reboot the instance for the changes to take effect.

Remember to create a backup of your instance before making any networking configuration changes, as incorrect modifications could potentially make the instance unreachable.

If you've recently changed the DHCP options and are not seeing the changes reflected, it's possible that the DHCP lease has not yet renewed. In this case, waiting for a few hours or initiating a reboot should resolve the issue.
Sources
Work with DHCP option sets - Amazon Virtual Private Cloud
Key concepts - Hybrid Cloud DNS Options for Amazon VPC
Configure an EC2 instance with a static DNS server | AWS re:Post

profile picture
answered 2 months ago
profile picture
EXPERT
reviewed 2 months ago
  • I modified the DHCP option set a week ago. The changes still don't reflect in the /etc/resolv.conf file of existing EC2 instances. I tried rebooting the instances, did not work.

0

Hello.

I think the changes will be reflected by restarting the EC2 instance itself, but I also think they can be reflected by restarting network-related services using the command below.

sudo systemctl restart network

By the way, as stated in the document below, the changes will be reflected automatically over time without having to reboot.
https://docs.aws.amazon.com/vpc/latest/userguide/DHCPOptionSet.html#ChangingDHCPOptionsofaVPC

When you associate a new set of DHCP options with a VPC, any existing instances and all new instances that you launch in that VPC use the new options. You don't need to restart or relaunch your instances. Instances automatically pick up the changes within a few hours, depending on how frequently they renew their DHCP leases. If you prefer, you can explicitly renew the lease using the operating system on the instance.

I modified the DHCP option set a week ago. The changes still don't reflect in the /etc/resolv.conf file of existing EC2 instances. I tried rebooting the instances, did not work.

Normally the DHCP lease period expires in a few hours, so it seems odd that it hasn't been reflected for a week.
Does your VPC have the newly created DHCP options set?
Double check that the newly created DHCP options set is configured in the VPC where your EC2 instance is running.

profile picture
EXPERT
answered 2 months ago
profile picture
EXPERT
reviewed 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions