macOS

Как изменить DNS на Mac: пошаговое руководство

Этот гайд подробно объясняет, как изменить DNS-серверы на macOS через графический интерфейс и терминал. Вы сможете улучшить скорость и безопасность соединения.

Updated at February 16, 2026
5-10 min
Easy
FixPedia Team
Применимо к:macOS 12 MontereymacOS 13 VenturamacOS 14 Sonoma

Introduction

DNS (Domain Name System) converts user-friendly website names (like google.com) into IP addresses that computers understand. By default, macOS uses DNS servers provided by your internet service provider. However, these servers may be slow, insecure, or block access to certain websites.

By switching DNS to public servers from Google, Cloudflare, or other providers, you can:

  • Speed up webpage loading through faster domain resolution.
  • Bypass regional blocks and censorship.
  • Improve security by using DNS with DNSSEC support and phishing filtering.

This guide will show you how to change DNS on a Mac in two ways: through the graphical interface and via the terminal.

Requirements

Before you begin, ensure that:

  • You have a Mac with macOS 12 or newer (instructions apply to Monterey, Ventura, Sonoma).
  • You are logged in with an administrator account (a password may be required to apply system settings).
  • You have an active network connection (Wi-Fi or Ethernet).
  • You know the DNS server addresses you want to use. Popular options:
    • Google DNS: 8.8.8.8 and 8.8.4.4
    • Cloudflare DNS: 1.1.1.1 and 1.0.0.1
    • OpenDNS: 208.67.222.222 and 208.67.220.220

Method 1: Change DNS via System Settings

This method is suitable for most users and does not require command-line work.

Step 1: Open Network Settings

  1. Click the Apple menu (∧) in the top-left corner of the screen.
  2. Select "System Settings".
  3. In the sidebar, find and click "Network".

💡 Tip: In macOS Ventura and earlier versions, the section may be called "Network" in the "System Settings" window. The Sonoma interface is similar.

Step 2: Select Active Connection and Open DNS Settings

  1. From the list of network interfaces on the left, select your active connection:
    • For a wired connection — Ethernet.
    • For wireless — Wi-Fi (it should be highlighted in green).
  2. Click the "Advanced" button in the bottom-right corner of the window.
  3. A new window will open. Navigate to the "DNS" tab.

Step 3: Add DNS Servers

  1. Click the "+" (plus) button below the list of DNS servers.
  2. Enter the DNS server address (e.g., 8.8.8.8). Press Enter.
  3. Repeat for the second server (e.g., 8.8.4.4). You can add more servers, but two are usually sufficient.
  4. To remove an old DNS server, select it in the list and click "-" (minus).

⚠️ Important: Ensure the added DNS servers are first in the list. macOS uses them in priority order. Drag them up if needed.

Step 4: Save Changes

  1. Click "OK" in the bottom-right corner of the "Advanced" window.
  2. Back in the network window, click "Apply" to save the settings. Changes take effect immediately.

Method 2: Change DNS via Terminal

This method is useful for automation, remote management, or if the graphical interface is unavailable.

Step 1: Identify the Network Service Name

  1. Open Terminal from the "Utilities" folder or via Spotlight (Cmd+Space, type "Terminal").
  2. Enter the command to list network services:
    networksetup -listallnetworkservices
    
  3. Find the name of your active connection (e.g., Wi-Fi or Ethernet) in the output. Note that names may contain spaces or quotes.

Step 2: Set DNS Servers

Use the networksetup command, specifying the service and DNS addresses.

Example for Wi-Fi:

sudo networksetup -setdnsservers "Wi-Fi" 8.8.8.8 8.8.4.4

Example for Ethernet:

sudo networksetup -setdnsservers "Ethernet" 1.1.1.1 1.0.0.1

⚠️ Important:

  • The command requires an administrator password (enter it when prompted; characters are not displayed).
  • If the service name contains spaces, enclose it in quotes.
  • To revert to automatic DNS (from your provider), run:
    sudo networksetup -setdnsservers "Wi-Fi" Empty
    

Step 3: Verify Current DNS Settings (Optional)

Confirm that DNS has changed:

networksetup -getdnsservers "Wi-Fi"

The output should display the addresses you added.

Verify the Result

After changing DNS, ensure the settings work correctly:

  1. Restart your browser or network-using applications.
  2. Check domain resolution via nslookup in Terminal:
    nslookup google.com
    

    Look for the "Address" line in the output — it should correspond to the IP address for google.com. If DNS is working, the command will return an address without errors.
  3. For a more detailed check, use dig (if installed via Homebrew):
    dig google.com
    

    The IP address should appear in the "ANSWER SECTION".
  4. Test speed: visit several websites, especially those that previously loaded slowly. If DNS was the bottleneck, loading should be faster.

Potential Issues

Issue 1: Changes Not Applied

  • Cause: The "Apply" button in network settings wasn't clicked, or the networksetup command was run without sudo.
  • Solution: In the graphical interface, always click "Apply". In the terminal, use sudo and enter your password.

Issue 2: No Internet Access After DNS Change

  • Cause: Incorrect DNS server addresses or a temporary outage with the DNS provider.
  • Solution: Revert to your previous DNS servers (or select "Automatic"). Verify that the chosen DNS servers are reachable (e.g., 8.8.8.8 should respond to ping).

Issue 3: DNS Queries Still Going to Old Server

  • Cause: DNS cache on your Mac or router.
  • Solution: Clear the macOS DNS cache:
    sudo dscacheutil -flushcache
    sudo killall -HUP mDNSResponder
    
    If you use a router, reboot it.

Issue 4: Conflict with VPN or Antivirus

  • Cause: Some VPN clients or security programs override DNS settings.
  • Solution: Configure DNS within the VPN application or disable it for testing. Check your antivirus settings.

Issue 5: Terminal Cannot Find Service

  • Cause: Incorrect network service name (e.g., "Wi-Fi" vs. "Wi-Fi" with quotes).
  • Solution: Check the exact name via networksetup -listallnetworkservices. Ensure you use the precise name, including spaces and capitalization.

F.A.Q.

Can you change DNS on macOS without admin rights?
Which DNS is best to choose for Mac?
Does changing DNS affect internet speed?
How to revert to default DNS on Mac?

Hints

Откройте Системные настройки
Выберите активное подключение
Добавьте DNS-серверы
Примените изменения
FixPedia

Free encyclopedia for fixing errors. Step-by-step guides for Windows, Linux, macOS and more.

© 2026 FixPedia. All materials are available for free.

Made with for the community