Set custom DNS servers with nmcli

Point a Wi-Fi or wired profile at faster or privacy-friendly resolvers like 1.1.1.1.

LinuxnmclinetworkDNSnetworkmanagerLow risk
Run nmcli con mod 'MyWiFi' ipv4.dns '1.1.1.1 8.8.8.8' plus ipv4.ignore-auto-dns yes, then reactivate with nmcli con up 'MyWiFi'.

01Command

Command
$ nmcli con mod 'MyWiFi' ipv4.dns '1.1.1.1 8.8.8.8' && nmcli con mod 'MyWiFi' ipv4.ignore-auto-dns yes && nmcli con up 'MyWiFi'

02What it does

NetworkManager stores DNS per connection profile, so you can give your home Wi-Fi different resolvers than your office network. ipv4.ignore-auto-dns yes is the step people miss — without it the router's DHCP-provided DNS keeps winning. Get the exact profile name first with nmcli con show, then the change applies as soon as the connection reactivates.

03Risk

RiskLow risk
RequirementsNetworkManager (default on Ubuntu/Fedora desktops); replace 'MyWiFi' with a name from nmcli con show
!Warning: Typing the profile name wrong edits nothing (use quotes for names with spaces); if sites stop resolving, revert with ipv4.ignore-auto-dns no and empty ipv4.dns.

04Undo

Undo
$ nmcli con mod 'MyWiFi' ipv4.ignore-auto-dns no && nmcli con mod 'MyWiFi' ipv4.dns '' && nmcli con up 'MyWiFi'

05Sources

  • NetworkManager — Arch Wiki
    Arch Linux · community · 2026-09-17
    Evidence: Custom DNS servers are set per connection with nmcli con mod <name> ipv4.dns, and ignore-auto-dns stops DHCP-provided DNS overriding them.
  • nmcli(1) — Ubuntu manual page
    Ubuntu · community · 2026-09-17
    Evidence: nmcli con mod modifies connection properties such as ipv4.dns and ipv4.ignore-auto-dns; nmcli con up reactivates the profile to apply them.

Last verified: 2026-09-18 · Category: Network

06Related solutions