Skip to content

Instantly share code, notes, and snippets.

@pgp
Last active November 21, 2020 18:02
Show Gist options
  • Save pgp/5fe0f95b28d59cf667649fefcffdc7d6 to your computer and use it in GitHub Desktop.
Save pgp/5fe0f95b28d59cf667649fefcffdc7d6 to your computer and use it in GitHub Desktop.
# 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=mypridomain.com

# Set Listen address
listen-address=::1,127.0.0.1,192.168.1.1
server=1.1.1.1
server=<put-here-your-company-dns-internal-address> <----------------------
address=/nonvisible.com/127.0.0.1
  • Prevent NetworkManager from recreating /etc/resolv.conf:

sudo nano /etc/NetworkManager/NetworkManager.conf

[main]
plugins=ifupdown,keyfile
dns=none  # <----------

[ifupdown]
managed=false

[device]
wifi.scan-rand-mac-address=no
  • ensure /etc/resolv.conf is empty:
sudo rm /etc/resolv.conf
sudo touch /etc/resolv.conf
sudo chmod 777 /etc/resolv.conf
  • ensure dnsmasq service is enabled:
sudo systemctl enable dnsmasq
  • reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment