How to Add a Static DNS Entry in Windows 11

Published by Nyau Wai Hoe - Updated on

The ability to add static Domain Name System (DNS) entries on your computer can be an invaluable tool for managing network configurations, testing websites during development, or blocking access to specific sites. In Windows 11, creating a static DNS entry allows you to associate a specific IP address with a domain name, bypassing the need for DNS resolution and potentially speeding up access to certain servers.

This comprehensive guide will provide you with step-by-step instructions for adding a static DNS entry in Windows 11 and delve into advanced topics related to DNS and the hosts file.

How to Add a Static DNS Entry in Windows 11


Before getting started, you should be familiar with the following concepts:

  • DNS: Domain Name System is a system that translates human-readable domain names, such as, into IP addresses that computers use to identify each other on the internet.
  • Static DNS entry: A manually created DNS record that associates a domain name with a specific IP address, bypassing the need for DNS resolution.
  • Administrator rights: You will need administrator rights on your computer to follow these steps, as modifying the DNS settings requires elevated permissions.

Linked issue: Access Denied When Editing Hosts File in Windows 11/10

Adding a static DNS entry in Windows 11

To add a static DNS entry in Windows 11, follow these steps:

  1. Open the File Explorer by clicking on the File Explorer icon in the taskbar or pressing Win + E.
  2. Navigate to the hosts file located at C:\Windows\System32\drivers\etc. In the etc folder, you will find a file named hosts. This file contains the static DNS entries for your system.
  3. Create a backup of the hosts file by right-clicking on it, selecting Copy, and then pasting it into another folder. This step is essential because it allows you to revert to the original file if you make any mistakes or encounter issues.Backup hosts file in Windows 11
  4. Open Notepad or another text editor with administrator rights by pressing Win + S to open the search bar, typing “Notepad” or the name of your preferred text editor, right-clicking on the result, and selecting Run as administrator.Open Notepad as administrator
  5. After opening the text editor with administrator rights, click on File in the top-left corner, then select Open.Notepad File Open
  6. Navigate to the hosts file located at C:\Windows\System32\drivers\etc. Select the hosts file and click Open. Note: If you can’t see the hosts file and the window displays “No items match your search”, make sure to select the “All files” option first. This will allow the hosts file to appear in the window.How to open hosts file as administrator in Windows 11
  7. Add your static DNS entry by navigating to the end of the file and typing the IP address you want to associate with a domain name, followed by a space, and then the domain name itself. For example, to add a static DNS entry for with the IP address, you would add the following line to the file:

    Add static DNS entries Windows 11
    You can also add comments in the file by starting a line with a # symbol. Comments are useful for documenting the purpose of specific entries or providing additional information.

  8. Save the changes by clicking on File in the top-left corner of the text editor and selecting Save.
  9. Close the text editor and restart your computer to apply the changes.

Useful tip: How to Use Netsh Interface IP Set Address or DNS in CMD

Verifying the static DNS entry

To verify that your static DNS entry is working correctly, follow these steps:

  1. Open Command Prompt by pressing Win + S to open the search bar, typing “Command Prompt” or “cmd” in the search bar, and then pressing Enter.
  2. Test the DNS resolution by typing ping followed by the domain name you added to the hosts file and pressing Enter. For example:

    Verify static DNS entry in WindowsIf the static DNS entry was added successfully, the Command Prompt should display the IP address you specified in the hosts file.

Related problem: Some Websites Not Loading in Windows 11 (Fix)

Troubleshooting common issues

If you encounter issues while adding a static DNS entry in Windows 11, consider the following troubleshooting tips:

  • Ensure that the IP address and domain name you entered in the hosts file are correct and properly formatted.
  • Double-check that you have saved the changes to the hosts file before restarting your computer.
  • Verify that you have administrator rights on your computer, as modifying the hosts file requires elevated permissions.
  • Make sure there are no typos, extra spaces, or special characters in the hosts file that might cause parsing errors.
  • If you are still having trouble, restore the original hosts file using the backup you created earlier and try the process again.

The “hosts” file explained

The hosts file is a plain text file that resides in the C:\Windows\System32\drivers\etc directory. It is used to map domain names to IP addresses, allowing you to create custom DNS entries on your local system. These entries can override the information provided by your DNS server, making them useful for various purposes, such as testing a website during development, blocking access to certain sites, or speeding up access to specific servers.

Each line in the hosts file consists of an IP address, followed by one or more domain names separated by whitespace. Lines beginning with a # symbol are treated as comments and ignored by the system. Here is an example of a hosts file with multiple entries: localhost
# This is a comment explaining the entry below

IPv6 support in the hosts file

In addition to IPv4 addresses, the hosts file also supports IPv6 addresses. To add a static DNS entry for an IPv6 address, follow the same process as for IPv4, but use the IPv6 address format:


Add IPv6 static DNS entry in Windows 11

Advanced use cases for static DNS entries

  1. Local website development: If you are developing a website on your local machine, you can use the hosts file to map the domain name to your computer’s IP address ( or ::1 for IPv6). This way, you can test the website using the domain name before it goes live on the internet.
  2. Blocking access to websites: By adding a static DNS entry that maps a domain name to an invalid IP address (such as, you can effectively block access to that website on your computer. This technique can be useful for preventing access to distracting or malicious sites.
  3. Testing DNS changes: If you are migrating a website to a new server or making changes to your DNS configuration, you can use the hosts file to test the new settings before updating your DNS records. This allows you to verify that the changes are correct and minimize potential downtime during the transition.
  4. Network troubleshooting: In some cases, you may need to bypass your DNS server or use a specific IP address to access a server. Adding a static DNS entry in the hosts file can help you diagnose and resolve network issues more efficiently.

Best practices for managing the hosts file

  1. Backup regularly: Before making any changes to the hosts file, always create a backup to ensure you can quickly revert to the original settings if needed.
  2. Use comments: Including comments in the hosts file can help you remember the purpose of each entry and make it easier to maintain and troubleshoot.Windows hosts file comments
  3. Organize entries: Group related entries together and use whitespace or horizontal lines (e.g., # ----) to separate different sections for improved readability.
  4. Remove obsolete entries: Periodically review the hosts file and remove any entries that are no longer needed to keep the file clean and up-to-date.
  5. Test changes: After making changes to the hosts file, always test the new settings to ensure they are working as expected. This can help you identify any errors or potential issues before they cause problems on your system.
  6. Restrict access: Since the hosts file can significantly impact your system’s behavior, it is important to restrict access to it. Make sure only users with administrator rights can modify the file to prevent unauthorized changes.
  7. Consider alternative methods: If you find yourself frequently modifying the hosts file, consider using alternative methods for managing DNS entries, such as configuring a local DNS server or using a third-party DNS management tool. These solutions can offer more advanced features and greater flexibility than manually editing the hosts file.

Wrapping up

Adding a static DNS entry in Windows 11 is a powerful technique that provides you with greater control over your system’s network configurations and interactions with specific domain names. By following the steps outlined in this guide, you can easily add, modify, or remove static DNS entries on your Windows 11 system.

Remember to always create a backup of the hosts file before making any changes, and keep your entries organized and documented with comments for easy maintenance.

Categories: NetworkWindows 11

Nyau Wai Hoe
Nyau Wai Hoe is the Founder and Chief Editor of With a degree in software engineering and over 12 years of experience in the tech support industry, Nyau has established himself as an expert in the field, with a primary focus on the Microsoft Windows operating system. As a tech enthusiast, he loves exploring new technologies and leveraging them to solve real-life problems.

Share via
Copy link