Dnsmasq: Difference between revisions
No edit summary |
|||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
dnsmasq provides LAN DNS caching, as well as static IPs for all your local machine names via their MAC addresses. It's perfect! | dnsmasq provides LAN DNS caching, as well as static IPs for all your local machine names via their MAC addresses. It's perfect! | ||
You don't even need | You don't even need systemd or to fiddle with wifi router, just let dnsmasq do it all. Fuck yeah. | ||
==== | == Show leases == | ||
mh-watch-leases | |||
# which does this: ssh -t bp watch -n 1 cat /var/lib/misc/dnsmasq.leases | |||
==== Adding a new host | == Release leases == | ||
You have to stop, remove leases from the leases file, and restart dnsmasq: | |||
sudo service dnsmasq stop && sudo emacs /var/lib/misc/dnsmasq.leases && sudo service dnsmasq start | |||
== Configuration == | |||
Main config is here: | |||
bitpost:/etc/dnsmasq/mdm_lan_dnsmasq.conf | |||
Provide LAN DHCP range: | |||
# MDM LAN ubuntu interface | |||
dhcp-range=enp5s0f1, ... | |||
Provide WAN interface: | |||
# MDM WAN interface: 10g Intel NIC | |||
interface=enp10s0f1 | |||
Dnsmasq will be all we need for all DNS: | |||
# Make clients that request IPs use this box for DNS | |||
dhcp-option=option:router,192.168.22.1 | |||
Allow "single-label" (LAN name) DNS lookups (without a dot suffix): | |||
# MDM We have to get systemd-resolved to allow "single-label" DNS lookups. | |||
# This seems to do the trick. Whew. | |||
# https://askubuntu.com/questions/917784/systemd-resolved-does-not-query-dns-server-for-local-domain | |||
# https://github.com/systemd/systemd/issues/13763 | |||
domain=bitpost.lan | |||
local=/bitpost.lan/ | |||
expand-hosts | |||
Provide upstream DNS right in the config file - relying on /etc/resolv.conf was a nightmare. | |||
# MDM add upstream cloudflare DNS servers here, as /etc/resolv.conf isn't working and is constantly fucked with! | |||
# This gets the job done so that the entire LAN can go through bitpost DNS to get to cloudflare DNS. Yes! | |||
server=1.1.1.1 | |||
server=1.0.0.1 | |||
Finally... the LAN static IPs... | |||
#========================================================================================================= | |||
# MDM MY STATIC IPs! Sync with /etc/hosts on bitpost! Everything that uses bitpost for DHCP will work! | |||
# To see what has been given a dhcp lease: bitpost ~ # cat /var/lib/misc/dnsmasq.leases | |||
#========================================================================================================= | |||
dhcp-host=(MAC),bitpost,(IP) # main router/abt server; aka [bp] | |||
dhcp-host=(MAC),case,(IP) # wired 319 living room kodi + backup gaming rig | |||
(etc.) | |||
=== Adding a new host === | |||
Add a new line to the config file with an available IP, and host and MAC of the new box. | Add a new line to the config file with an available IP, and host and MAC of the new box. | ||
=== Windows DNS resolution === | |||
Windows apparently puts a suffix on names, unless you end them with a dot, so sometimes in Windows you have to use something like this: | Windows apparently puts a suffix on names, unless you end them with a dot, so sometimes in Windows you have to use something like this: | ||
\\hive.\reservoir | \\hive.\reservoir | ||
=== Disable systemd-resolved === | |||
NOTE this totally replaces systemd-resolved THANK the lord - disable that shit! | |||
systemctl disable systemd-resolved.service | |||
systemctl stop systemd-resolved.service | |||
# MDM not sure this is needed- i'd like to remove resolv.conf entirely... there is a way but i'll wait until i'm home to try it... | |||
rm /etc/resolv.conf | |||
ln -s /run/resolvconf/resolv.conf /etc/resolv.conf | |||
# this will remove the resolved stub resolver entry from resolv.conf | |||
resolvconf -d systemd-resolved |
Latest revision as of 05:46, 15 December 2024
dnsmasq provides LAN DNS caching, as well as static IPs for all your local machine names via their MAC addresses. It's perfect!
You don't even need systemd or to fiddle with wifi router, just let dnsmasq do it all. Fuck yeah.
Show leases
mh-watch-leases # which does this: ssh -t bp watch -n 1 cat /var/lib/misc/dnsmasq.leases
Release leases
You have to stop, remove leases from the leases file, and restart dnsmasq:
sudo service dnsmasq stop && sudo emacs /var/lib/misc/dnsmasq.leases && sudo service dnsmasq start
Configuration
Main config is here:
bitpost:/etc/dnsmasq/mdm_lan_dnsmasq.conf
Provide LAN DHCP range:
# MDM LAN ubuntu interface dhcp-range=enp5s0f1, ...
Provide WAN interface:
# MDM WAN interface: 10g Intel NIC interface=enp10s0f1
Dnsmasq will be all we need for all DNS:
# Make clients that request IPs use this box for DNS dhcp-option=option:router,192.168.22.1
Allow "single-label" (LAN name) DNS lookups (without a dot suffix):
# MDM We have to get systemd-resolved to allow "single-label" DNS lookups. # This seems to do the trick. Whew. # https://askubuntu.com/questions/917784/systemd-resolved-does-not-query-dns-server-for-local-domain # https://github.com/systemd/systemd/issues/13763 domain=bitpost.lan local=/bitpost.lan/ expand-hosts
Provide upstream DNS right in the config file - relying on /etc/resolv.conf was a nightmare.
# MDM add upstream cloudflare DNS servers here, as /etc/resolv.conf isn't working and is constantly fucked with! # This gets the job done so that the entire LAN can go through bitpost DNS to get to cloudflare DNS. Yes! server=1.1.1.1 server=1.0.0.1
Finally... the LAN static IPs...
#========================================================================================================= # MDM MY STATIC IPs! Sync with /etc/hosts on bitpost! Everything that uses bitpost for DHCP will work! # To see what has been given a dhcp lease: bitpost ~ # cat /var/lib/misc/dnsmasq.leases #========================================================================================================= dhcp-host=(MAC),bitpost,(IP) # main router/abt server; aka [bp] dhcp-host=(MAC),case,(IP) # wired 319 living room kodi + backup gaming rig (etc.)
Adding a new host
Add a new line to the config file with an available IP, and host and MAC of the new box.
Windows DNS resolution
Windows apparently puts a suffix on names, unless you end them with a dot, so sometimes in Windows you have to use something like this:
\\hive.\reservoir
Disable systemd-resolved
NOTE this totally replaces systemd-resolved THANK the lord - disable that shit! systemctl disable systemd-resolved.service systemctl stop systemd-resolved.service
- MDM not sure this is needed- i'd like to remove resolv.conf entirely... there is a way but i'll wait until i'm home to try it...
rm /etc/resolv.conf ln -s /run/resolvconf/resolv.conf /etc/resolv.conf
- this will remove the resolved stub resolver entry from resolv.conf
resolvconf -d systemd-resolved