brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: dhcp4-overrides lets netplan ignore the DNS servers a DHCP server sends

Netplan
~/tips/tip-netplan-dhcp4-overrides-use-dns

network: {version: 2, ethernets: {enp3s0: {dhcp4: true, dhcp4-overrides: {use-dns: false}, nameservers: {addresses: [192.168.1.2]}}}}

Keeps the DHCP address but replaces the DNS servers with your own.

DHCP gives you an address and also a list of DNS servers. Sometimes you want one but not the other.

# /etc/netplan/63-dhcp.yaml
network: {version: 2, ethernets: {enp3s0: {dhcp4: true, dhcp4-overrides: {use-dns: false}, nameservers: {addresses: [192.168.1.2]}}}}

With use-dns: false, the interface keeps its lease but ignores the DNS servers from it, so the nameservers you list are the ones in use. Check the effect with resolvectl status enp3s0. The same block has use-routes, route-metric and use-ntp, which control the routes, their metric and the NTP servers from DHCP. Run netplan try to test it.

Further reading: Netplan YAML configuration reference

More Netplan tips – to: 192.168.3.0/24 hidden: true lacp-rate: fast link-local: [] wakeonlan: true All Netplan tips (21) All topics

Link