0

Using Ubuntu 20.04 LTS on a Raspberry Pi and trying to setup a DNS and DCHP Server on it using DNSMasq

Got to the point where I want to add static DNS results in the /etc/hosts file however when I reboot all of the work I've done disappears and it resets.

Looking closer at the /etc/hosts file it says:

# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.debian.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
#     /etc/cloud/cloud.cfg or cloud-config from user-data

I tried:

  • Adding manage_etc_hosts: false under preserve_hostname: false in /etc/cloud/cloud.cfg
  • Removing manage_etc_hosts: True in /etc/cloud/templates/hosts.debian.tmpl
  • grep -r manage_etc_hosts /etc/cloud which returned files with " included which was only the template files. I don't know how to edit the "cloud-config from user-data"

Can anyone help

Thanks

Jacob

1 Answers1

0

Edit your /etc/cloud/cloud.cfg file and comment out the line that has - update_etc_hosts like so

cloud_init_modules:
  - migrator
  - seed_random
  - bootcmd
  - write-files
  - growpart
  - resizefs
  - disk_setup
  - mounts
  - set_hostname
  - update_hostname
  # - update_etc_hosts
  - ca-certs
  - rsyslog
  - users-groups
  - ssh

Reboot and your changes to /etc/hosts should remain after reboot

SiegeX
  • 567
  • 1
  • 6
  • 16