4

I have an AWS VPC that by mistake had the default DHCP option set cleared. As a result I have a handful of servers that have the wrong (unresolvable) hostnames and missing settings in /etc/resolv.conf.

I have fixed the VPC to use the default DHCP option set. Is there a way to get the servers to pick up these changes?

1 Answer 1

3

You can't push the new DHCP settings to the hosts from outside I'm afraid.

You can either:

  1. Reboot the instances - probably the best as it ensures that the old settings are not cached in any running programs, or
  2. Restart its network stack (e.g. systemctl restart networking.service in Ubuntu), or
  3. Wait for the DHCP lease to expire, it should then renew with the new settings, or
  4. Fix /etc/resolv.conf manually if you know what you're doing.
  5. If you also need to fix the hostname you can remove /var/lib/cloud/instance (it's a symlink) and reboot. That should re-run you (or default) cloud-init script that sets the hostname. Test it first on a test instance.

Hope that helps :)

5
  • thank you so much for the response. I've tried rebooting but it didn't help. Calling curl http://169.254.169.254/latest/meta-data/local-hostname still returns the wrong hostname (i.e. it's just the ip w/o the domain). I can edit /etc/resolv.conf, but those setting are overwritten on reboot. I found that I can stop and restart the instance to resolve the issue. However, the instance in question is an i3 w/ 2 TB of data that will be lost if I stop the instance. Feb 25, 2019 at 20:39
  • Just pointing out the obvious @herbrandson that if the data is important you need to have the data on the instance store backed up, in case of hardware failure or operator error (stop / start). Hopefully you can find a way to get your DHCP working without having to stop / start / restore the data.
    – Tim
    Feb 25, 2019 at 20:42
  • Yes, the data is backed up. But, it takes a long time to restore (and I actually need to do this on ~30 nodes). It's not the end of the world if I have to stop and restart... it'll just take forever. Feb 25, 2019 at 20:44
  • @herbrandson If reboot doesn't pick up the new settings (which surprises me) it also shouldn't revert your changes if you change resolv.conf manually. On the other hand resolv.conf is only used for DNS (nameserver list, search domain) but you also mentioned hostname - that's probably set through cloud-init. You can remove /var/lib/cloud/instance and reboot - that will re-run your (or default) cloud-init script and reset the hostname. Try it on a test instance first!
    – MLu
    Feb 25, 2019 at 21:00
  • A full stop/start of the instance solved the dhcp issues for me, specifically an incorrect local-hostname in ec2metadata.
    – Banjer
    Feb 27, 2020 at 17:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.