Disable /etc/hosts From Reset at Boot
From: https://serverfault.com/questions/1108760/how-to-disable-etc-hosts-from-resetting-after-reboot
1.) Disable systemd-resolved.service
sudo systemctl disable systemd-resolved
2.) Stop systemd-resolved.service
sudo systemctl stop systemd-resolved
3.) Also, remove the symlinked resolv.conf file
ls -lh /etc/resolv.conf
4.) Unlink it
sudo unlink /etc/resolv.conf
5.) Then create new resolv.conf file.
echo nameserver 8.8.8.8 | sudo tee /etc/resolv.conf
Dnsmasq is available on the apt repository, Info
easy installation can be done by running
6.) Install dnsmasq
sudo apt install dnsmasq
7.) Edit dnsmasq.conf
sudo vim /etc/dnsmasq.conf
Here is minimal configuration
# Listen on this specific port instead of the standard DNS port
# (53). Setting this to zero completely disables DNS function,
# leaving only DHCP and/or TFTP.
port=53
# Never forward plain names (without a dot or domain part)
domain-needed
# Never forward addresses in the non-routed address spaces.
bogus-priv
# By default, dnsmasq will send queries to any of the upstream
# servers it knows about and tries to favour servers to are known
# to be up. Uncommenting this forces dnsmasq to try each query
# with each server strictly in the order they appear in
# /etc/resolv.conf
strict-order
# Set this (and domain: see below) if you want to have a domain
# automatically added to simple names in a hosts-file.
expand-hosts
# Set the domain for dnsmasq. this is optional, but if it is set, it
# does the following things.
# 1) Allows DHCP hosts to have fully qualified domain names, as long
# as the domain part matches this setting.
# 2) Sets the "domain" DHCP option thereby potentially setting the
# domain of all systems configured by DHCP
# 3) Provides the domain part for "expand-hosts"
#domain=thekelleys.org.uk
domain=example.com
# Set Listen address
listen-address=127.0.0.1 # Set to Server IP for network responses
8.) Restart dnsmasq
sudo systemctl restart dnsmasq
9.) Edit the hosts file. Add your own entries.
sudo vim /etc/hosts
10.1.3.4 server1.mypridomain.com
10.1.4.4 erp.mypridomain.com
192.168.10.2 checkout.mypridomain.com
192.168.4.3 hello.world
10.) Restart dnsmasq
sudo systemctl restart dnsmasq
11.) Add the locahost to the resolv.conf at the first place
sudo vim /etc/resolv.conf
nameserver 127.0.0.1
nameserver 8.8.8.8