Linux’s default file that defines what DNS servers will be used /etc/resolv.conf typically contains directives with the default search domain or domains; used for FQDN (Fully Qualified Domain Name) completion when no domain suffix is supplied as part of the DNS query. Lets say sub-domains under domain.com has to be accessed (in /etc/resolv.conf) there is:
search domain.com
That is very handy whether you have to ssh or open in web browser (sites) or multiple servers each residing under a single main domain name (for example:
server1.domain.com, server2.domain.com, server3.domain.com etc.) by typing in browser or SSH by only passing the sub-domain name i.e.:
http://server1
http://server2
or
ssh user@server1
ssh user@server2
Here is /etc/resolv.conf from www.pc-freak.net
# cat /etc/resolv.conf
domain www.pc-freak.net
search www.pc-freak.net bergon.net
Here is example of what I mean, ascii-games is a sub-domain of www.pc-freak.net (ascii-games.www.pc-freak.net) and is resolved with no need to type full FQDN
# host ascii-games
ascii-games.www.pc-freak.net has address 83.228.93.76
The DNS server knows that all failed to resolve queries by set DNS should be searched (resolved) under the defined search domain, i.e. each DNS query for server2, serverX (would try to be resolved as a subdomain of domain.com).
Therefore, a very good question is what is Microsoft Windows (2000, 2003, OS equivalent way to define search domain.com into /etc/resolv.conf?
In Windows the same /etc/resolv.conf hosts search is done using the so called «DNS Suffixes«.
DNS Suffixes are used for resolv of (domain name strings with no dots).
Adding a new DNS Suffix in Windows is done from
Control Panel -> Network and Sharing Center -> Change Adapter Settings
Here select LAN card Adapter used to bring Internet to Win host,be it Local Area Connection or
Wireless Network Connection
and choose:
Properties
From
Network Connection Properties
dialog select
Internet Protocol Version 4 (TCP/IPv4)
and again click on
Properties
On next dialog click on
Advanced (button) -> DNS (tab)
In field
DNS Suffix for this connection
fill in host which you would like to resolve with no need for FQDN and press the
Add
(exactly like adding search www.pc-freak.net in /etc/resolv.conf on Linux host). Add multiple hosts DNS Suffix, if you want to access subdomains naming from multiple base domain.
Download PDF
Tags: com, configure, DNS, domain name, Fully Qualified Domain Name, How to, multiple, resolve, server1, server2, ssh, web browser
This entry was posted on Thursday, June 26th, 2014 at 12:58 pm and is filed under Everyday Life, System Administration, Various, Windows. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
DNS configuration sets up a Domain Name System server to translate domain names (URLs) into IP addresses. The configuration helps manage the DNS records for domains.
Knowing how to configure a DNS server is essential for any network administrator. The steps to configure a DNS differs depending on the operating system.
This article shows how to configure DNS on a Windows, macOS, and Linux machine.
Prerequisites
- A stable internet connection.
- Access to an account with administrator privileges.
- Access to the command line/terminal.
Why Change DNS Configuration?
Internet service providers use a preconfigured DNS server to filter traffic. There are many reasons to change the default DNS configuration, such as:
- Speed improvements. A DNS maps domain names to IP addresses. Custom DNS configuration helps improve domain name resolution times, which reduces the time needed to access a website.
- Greater security. Specific DNS servers block malicious web pages and focus on preventing access to unsafe websites. Changing the DNS configuration to use such servers improves internet security and restricts exposure to online threats.
- Customized experience. Configure the DNS to block access to specific web pages or reroute domain names to different addresses. For example, some DNS servers help create a family-friendly environment by blocking access to unsafe or suspicious websites.
- Privacy. Some DNS servers log internet queries for advertising purposes. Changing the DNS configuration to a privacy-focused server enables better control over online privacy.
- Troubleshooting. Changing to a different DNS server is crucial in troubleshooting DNS issues.
There are many free DNS resolvers available. While some solely focus on reducing DNS lookups and speed improvements, other resolvers aim to provide an additional security and filtering layer.
The table below shows example providers, the purpose of the DNS, and the IPv4 and IPv6 addresses:
Provider | Purpose | IPv4 Addresses | IPv6 Addresses |
---|---|---|---|
Speed improvements. | 8.8.8.8 8.8.4.4 |
2001:4860:4860::8888 2001:4860:4860::8844 |
|
Cloudflare | Speed improvements. | 1.1.1.1 1.0.0.1 |
2606:4700:4700::1111 2606:4700:4700::1001 |
Quad9 | Filters malware, phishing, and exploits. | 9.9.9.9 149.112.112.112 |
2620:fe::fe 2620:fe::9 |
OpenDNS | Security filtering and user-defined policies. | 208.67.222.222 208.67.220.220 |
2620:119:35::35 2620:119:53::53 |
The table shows a brief list of popular DNS servers. Research further to find a DNS resolver for your use case.
How to Change DNS Configuration on Windows
Changing the DNS configuration on Windows OS requires administrator privileges. Below are instructions to change the DNS configuration on a Windows 10/11 or Windows Server machine.
Windows 10/11
To change the DNS configuration on Windows, do the following:
1. In the Start menu, search for Network Status.
2. Select Change adapter options.
3. Right-click the network connection and open Properties.
4. Locate and select the Internet Protocol Version 4 (TCP/IPv4) option from the list.
5. Click the Properties button to open the IPv4 settings.
6. Select the Use the following DNS server addresses option.
7. Fill out the primary and secondary addresses. For example, to use Google’s DNS resolver addresses, set 8.8.8.8 as preferred and 8.8.4.4 as alternate.
8. Click OK to save the changes.
Restart the browser to apply the changes.
Windows Server
To change the DNS configuration on a Windows Server, follow the steps below:
1. Open the Start menu.
2. Search for Control Panel and press Enter.
3. Open the Network and Sharing Center.
4. In the left pane, select Change adapter settings.
The steps after this are similar to Windows 10/11 machines.
5. Right-click the connection and open Properties.
6. Double-click the Internet Protocol Version 4 (TCP/IPv4) option on the list.
7. Set the preferred and alternate DNS server address in the fields, and click OK to apply the changes.
Note: If you use an Active Directory domain, enter the loopback address from the IP field and set up a DNS forwarder with the public DNS addresses instead.
How to Change DNS Configuration on Linux
The following steps work on Ubuntu 22.04. The steps can slightly differ between different Linux distributions.
To permanently change the DNS configuration on Linux, do the following:
1. Open the terminal (Ctrl+Alt+T).
2. Open the resolv.conf file using a text editor, such as nano:
sudo nano /etc/resolv.conf
3. Add primary and alternate DNS addresses above the current configuration:
nameserver 8.8.8.8
nameserver 8.8.4.4
The addresses use Google’s DNS resolver. Replace the IPs with your preferred DNS.
4. Save the file and close nano.
5. To ensure the changes persist after restarting the machine, use the resolvconf tool. Install it with the following command:
sudo apt install resolvconf
Wait for the installation to complete and proceed to the next step.
6. Start and enable the service with the following two commands:
sudo systemctl start resolvconf.service
sudo systemctl enable resolvconf.service
7. Edit the configuration file:
sudo nano /etc/resolvconf/resolv.conf.d/head
8. Add the following lines above all other configurations:
nameserver 8.8.8.8
nameserver 8.8.4.4
9. Save the file and close the text editor.
10. Restart the service:
sudo systemctl restart resolvconf.service
11. Confirm the changes applied:
resolvectl status
The addresses show as the current DNS server for the Global settings. Alternatively, run the dig command:
dig phoenixnap.com
The SERVER section shows the DNS addresses.
How to Change DNS Configuration on macOS
To change the DNS configuration on macOS, follow the steps below:
1. Open Apple Menu->System Settings.
2. Open the Network settings from the left menu.
3. Choose the network from the list in the right pane (Wi-Fi or Ethernet).
4. Click the Details button to view the connection settings.
5. Switch to the DNS tab in the left pane.
6. Click the plus (+) button to add DNS server addresses.
7. Add the primary and secondary addresses for the DNS server.
8. Click OK to save the changes and apply the settings.
Restart the browser to test and see the changes.
How to Change DNS Configuration on Router Level?
Changing DNS configuration on a router level affects all connected devices, such as computers, smartphones, and any additional smart device that uses Wi-Fi. Routers that manage multiple signals, such as a phone or TV signal, often do not allow changing DNS settings at all.
The precise instructions to change the DNS configuration on a router are different for every model. Check the router’s instruction manual to see if there are specific steps and guidelines. Alternatively, search for the router name and model and add the «change DNS configuration» phrase.
Conclusion
After going through the steps in this guide, you know how to set up a custom DNS configuration on three different operating systems. Configuring DNS comes with many benefits, and it is essential for proper network administration.
Next, read about the best DNS practices for security and performance.
Was this article helpful?
YesNo
Содержание
Для корректного разрешения в системе доменных имен, необходимо прописать в ней адреса DNS-серверов.
В различных ОС это делается по-разному. Ниже приведены примеры с указанием публичных серверов ALFIS.
Системы c systemd-resolved
Этот способ подойдет для Ubuntu 15.10+, Mint 18.0+ и других дистрибутивов на базе Debian версии 8 и выше, а так же, дистрибутивов, в которых systemd установлен по-умолчанию (RHEL 7+, CentOS 7+, Fedora 15+ и др.).
В файл /etc/systemd/resolved.conf
нужно прописать следующее:
[Resolve] DNS=302:db60::53 300:6223::53 302:7991::53 300:170::53 Domains=~.
здесь перечислены адреса DNS-серверов через пробел, без указания номеров портов.
в отдельных случаях можно отключить директиву
DNSStubListener=no
Далее нужно выполнить перезапуск службы systemd-resolved:
sudo systemctl restart systemd-resolved
Системы без systemd
Способ подойдет для систем, где для конфигурирования основного системного резолвера используется файл /etc/resolv.conf
(Slackware, Debian и др.).
В файл /etc/resolv.conf
нужно прописать следующее:
- /etc/resolv.conf
-
nameserver 302:db60::53 nameserver 300:6223::53 nameserver 302:7991::53 nameserver 300:170::53
Выборка DNS осуществляется с верхнего в списке.
На случай отключения пира Yggdrasil, можно добавить аварийный CloudFlare и переключаться на него по тайм-ауту 5 секунд:
- /etc/resolv.conf
-
nameserver 301:5eb5:f061:678e::53 nameserver 1.1.1.1 options timeout:5
Дополнительные опции resolv.conf
описаны в документации.
Примечание: в некоторых случаях может потребоваться отключить для NetworkManager управление резолвером (если NetworkManager присутствует в системе):
В файле /etc/NetworkManager/NetworkManager.conf
, в секции [main]
добавляется строка:
dns=none
После этого внесенные изменения в /etc/resolv.conf
не будут перезаписываться при перезагрузке (перезапуске NetworkManager).
dhcp/resolvconf
Если в системе используется динамическая конфигурация dhcp/resolvconf, следует обратить внимание на файл /etc/dhcp/dhclient.conf
и закомментировать строки:
# domain-name, domain-name-servers, domain-search, host-name, # dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
Затем, добавить соответствующие nameserver в /etc/resolvconf/resolv.conf.d/base
и перезагрузить настройки:
resolvconf -u
Проверить результат можно командой dig
, в результирующем файле /etc/resolv.conf
необходимый сервер должен быть расположен в начале списка.
Windows
Щёлкаем ПКМ по иконке «Сеть» в системном трее, выбираем «Центр управления сетями и общим доступом». В открывшемся окне нажимаем «Изменение параметров адаптера», щёлкаем ПКМ на адаптере Yggdrasil, выбираем «Свойства», в открывшемся окне выделяем «Протокол Интернета версии 6», нажимаем кнопку «Свойства», в поле «Предпочитаемый DNS-сервер» прописываем: 302:db60::53, в поле «Альтернативный DNS-сервер» прописываем 300:6223::53, нажимаем ОК во всех окнах, где есть эта кнопка.
Так же, в Windows настроить DNS можно из командной строки:
netsh interface ip set dns name="Имя подключения" static 302:db60::53 netsh interface ip set dns name="Имя подключения" 300:6223::53 index=2
Можно использовать такой VB-скрипт:
Set oShell = CreateObject("Shell.Application") oShell.ShellExecute "netsh.exe", "interface ip set dns name=""Подключение по локальной сети"" static 302:db60::53", "", "runas", 0 oShell.ShellExecute "netsh.exe", "interface ip add dns name=""Подключение по локальной сети"" 300:6223::53 index=2", "", "runas", 0 'возврат к значениям, устанавливаемым DHCP 'oShell.ShellExecute "netsh.exe", "interface ip set dnsservers name=""Подключение по локальной сети"" source=dhcp", "", "runas", 0
Пример PowerShell-скрипта:
Set-DnsClientServerAddress -InterfaceAlias "Yggdrasil" -ServerAddresses ("302:7991::53", "302:db60::53", "300:6223::53", "324:71e:281a:9ed3::53")
Если Yggdrasil запускается, как системная служба, и вы хотите прописать DNS на адаптер Yggdrasil, то с помощью планировщика Windows можно создать задание, из которого будет запускаться нужный скрипт при активации нужного сетевого подключения. Пример можно посмотреть здесь: How to launch a command on network connection/disconnection?
Очистка кэша DNS
В некоторых случаях, когда меняется IP-адрес, к которому привязано доменное имя (например, если в ALFIS перемайнили домен на новый адрес), система продолжает выдавать старый IP-адрес. Это связано с кешированием данных DNS в вашей системе. В таких случаях нужно просто очистить кэш DNS.
Linux c systemd-resolved:
sudo systemd-resolve --flush-caches
Windows:
ipconfig /flushdns
Так же, может потребоваться очистить кэш браузера, которым вы пользуетесь.
Подробнее об этом можно почитать здесь или здесь.

The Windows Subsystem for Linux (WSL) is a powerful tool that allows developers to run a Linux environment directly on Windows without the overhead of a traditional virtual machine or dual-boot setup. However, like any system, it’s not without its quirks. One of the common issues users encounter is related to Domain Name System (DNS) resolution. In this article, we’ll explore how to fix DNS issues on WSL.
To fix DNS issues on Windows Subsystem for Linux (WSL), you can try updating the DNS server address in the /etc/resolv.conf file, disabling the generation of /etc/resolv.conf, checking firewall settings, or changing the network profile to Private. If none of these solutions work, it may be worth reaching out to the Microsoft WSL community for additional help.
- Understanding the Problem
- Solution 1: Update the DNS Server Address in /etc/resolv.conf
- Solution 2: Disable the Generation of /etc/resolv.conf
- Solution 3: Check Firewall Settings
- Solution 4: Change the Network Profile to Private
- Conclusion
Understanding the Problem
DNS issues in WSL typically manifest as an inability to connect to the internet or access specific websites. This is because DNS, which translates human-readable domain names into IP addresses that computers can understand, isn’t functioning correctly. The root of the problem often lies in the /etc/resolv.conf file, which WSL uses to determine which DNS servers to use.
Solution 1: Update the DNS Server Address in /etc/resolv.conf
The first solution involves directly editing the /etc/resolv.conf file to point to a different DNS server. Here’s how you can do it:
- Open the WSL terminal.
- Use a text editor to open the /etc/resolv.conf file. For example, you can use nano by typing
nano /etc/resolv.conf
. - In the file, you’ll see a line that looks like this:
nameserver 172.22.192.1
. This is the default DNS server address. Change it to a working DNS server address, such as1.1.1.1
(Cloudflare DNS) or8.8.8.8
(Google DNS). - Save the changes and exit the text editor. In nano, you can do this by pressing
Ctrl+X
, thenY
, thenEnter
. - Restart WSL and check if the DNS issue is resolved.
Solution 2: Disable the Generation of /etc/resolv.conf
If the first solution doesn’t work, you can try disabling the automatic generation of the /etc/resolv.conf file. This can be done by adding certain lines to the /etc/wsl.conf file. Here’s how:
- Open the WSL terminal.
- Use a text editor to create or edit the /etc/wsl.conf file. For example,
nano /etc/wsl.conf
. - Add the following lines to the file:
[network] generateResolvConf = false
This tells WSL not to generate a new /etc/resolv.conf file every time it starts.
- Save the changes and exit the text editor.
- Restart WSL and check if the DNS issue is resolved.
Solution 3: Check Firewall Settings
Sometimes, the issue might be due to the Windows Firewall blocking DNS requests from the WSL virtual machine. Here’s how to check and fix this:
- Open the Windows Firewall settings.
- Check if the firewall is blocking DNS requests from WSL. If necessary, whitelist WSL or change the firewall settings to allow DNS requests from WSL.
- Restart WSL and check if the DNS issue is resolved.
Solution 4: Change the Network Profile to Private
If you’re on a safe network, changing your network profile to Private can sometimes resolve DNS issues in WSL. Here’s how to do it:
- Open the Windows network settings.
- Change the network profile to Private.
- Restart WSL and check if the DNS issue is resolved.
Conclusion
DNS issues in WSL can be frustrating, but they’re usually not too difficult to fix. With the solutions provided above, you should be able to resolve most DNS problems you encounter. Remember, if you’re using a VPN, it may interfere with DNS resolution in WSL. If none of the above solutions work, try disconnecting the VPN and see if the DNS issue persists.
If you’re still having trouble, it may be worth reaching out to the Microsoft WSL community for additional help. They’re a knowledgeable and helpful bunch who are always willing to assist with WSL issues.
The Windows Subsystem for Linux (WSL) is a compatibility layer that allows users to run a Linux environment directly on Windows. It provides a command-line interface and supports running Linux binaries natively on Windows without the need for a virtual machine or dual-boot setup.
DNS issues in WSL refer to problems with Domain Name System (DNS) resolution, which can result in an inability to connect to the internet or access specific websites. DNS translates human-readable domain names into IP addresses that computers understand, and if it’s not functioning correctly in WSL, it can cause connectivity problems.
There are several solutions you can try to fix DNS issues in WSL. You can update the DNS server address in the /etc/resolv.conf file, disable the generation of /etc/resolv.conf, check firewall settings, or change the network profile to private. These solutions are explained in detail in the article above.
To update the DNS server address in /etc/resolv.conf, you need to open the WSL terminal, use a text editor to open the file (e.g., nano /etc/resolv.conf
), locate the line that starts with «nameserver», and change the IP address to a working DNS server address (e.g., 1.1.1.1 or 8.8.8.8). Save the changes and restart WSL to see if the DNS issue is resolved.
If updating the DNS server address doesn’t resolve the issue, you can try disabling the generation of /etc/resolv.conf by adding specific lines to the /etc/wsl.conf file. The steps for doing this are explained in solution 2 above.
Yes, the Windows Firewall can sometimes block DNS requests from the WSL virtual machine, causing DNS issues. You can check the firewall settings and whitelist WSL or change the settings to allow DNS requests from WSL. Solution 3 above provides more details on how to check and fix firewall settings.
Changing the network profile to private can sometimes resolve DNS issues in WSL, especially if you’re on a safe network. You can do this by opening the Windows network settings and changing the network profile to private. Solution 4 above provides more information on how to do this.
If none of the provided solutions work, it may be worth reaching out to the Microsoft WSL community for additional help. They have a GitHub repository (https://github.com/Microsoft/WSL) where you can seek assistance from knowledgeable individuals who specialize in WSL issues. Additionally, make sure to check if any VPN you’re using is interfering with DNS resolution in WSL and try disconnecting it to see if the issue persists.
I realize this thread is archaic but I «googled» to it and didn’t find my answer, but now I have it so I will share.
My take on this is if someone linux minded is asking about the resolv.conf for windows they could be looking for the same thing I was, suffix append.
For instance if your network domains are linux.corp, div1.linux.corp etc you want them to pre-pend to a shortname like master to make master.linux.corp or master.div1.linux.corp before going to the DNS servers for resolution.
That’s easy in Linux, just edit the resolv.conf and add.
search linux.corp div1.linux.corp
But where to put it in windows?
There is a dialog under the TCPIP properties, Advanced that lets you fill in that information.
Find your network adapter in network conecctions, right click, pick properties, then highlight the internet TCP/IP protocol and click the properties button. click the advanced button then the DNS tab. You’ll see a box for «Append these DNS suffixes (in order)» check it and put in your entries with commas between.
The effect is immediate although I have seen mention of a reboot required in some cases.