dnsmasq auf Ubuntu 22.04

Quelle: https://computingforgeeks.com/install-and-configure-dnsmasq-on-ubuntu/

1. DNS-Server

systemd-resolve deaktivieren

sudo systemctl disable systemd-resolved sudo systemctl stop systemd-resolved ls -lh /etc/resolv.conf sudo unlink /etc/resolv.conf

Neue resolv.conf-Datei erstellen

echo nameserver 8.8.8.8 | sudo tee /etc/resolv.conf

Installation

sudo apt update sudo apt install dnsmasq

Konfiguration: /etc/dnsmasq.conf

# Listen on this specific port # 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 # Reihenfolge wie in /etc/resolv.conf strict-order # Add domain name 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=btin.lan # Set Listen address listen-address=192.168.100.10 # Set to Server IP for network responses

Start

sudo systemctl restart dnsmasq

DNS-Einträge hinzufügen in /etc/hosts

192.168.100.101 web1.lan 192.168.100.101 web2.lan

Neustart

sudo systemctl restart dnsmasq

2. DHCP-Server

/etc/dnsmasq.conf

dhcp-range=192.168.100.20,192.168.100.30,1h dhcp-option=option:router,192.168.100.1 dhcp-option=option:ntp-server,192.168.100.1 dhcp-option=option:dns-server,192.168.100.10 dhcp-option=option:netmask,255.255.255.0

restart

sudo systemctl restart dnsmasq