Working with DNS from the Command Line in Windows (2024)

DNS

The Domain Name System (DNS) is a hierarchical distributed naming system for computers, services, or any resource connected to the Internet or a private network. It associates various information with domain names assigned to each of the participating entities. Most prominently, it translates domain names meaningful for users to the numerical IP addresses needed for the purpose of locating computer services and devices worldwide. By providing a worldwide, distributed keyword-based redirection service, the Domain Name System is an essential component of the functionality of the Internet.
  1. Open up the command prompt (In Windows, you can use WINDOWS KEY+R to open Run dialogue box and type cmd)
    (note: Use your up and down arrow keys to access recent commands you have entered in the command line.)
  2. To see your current DNS settings, type ipconfig /displaydns and press Enter.
  3. To delete the entries, type ipconfig /flushdns and press Enter.
  4. To see your DNS settings again, type ipconfig /displaydns and press Enter.
  5. You should see blank records or you might get the message "Could not display the DNS Resolver Cache."
  6. To perform a DNS lookup, type ping scisweb.ulster.ac.uk and press Enter.
  7. To see your DNS settings again, type ipconfig /displaydns and press Enter.
  8. You should see a DNS record for scisweb.ulster.ac.uk that includes the IP address and other information. Another field in the DNS cache is a TTL value, which is different from the TTL in an IP packet. This DNS TTL value is sent by the DNS server maintaining the scisweb.ulster.ac.uk record. It is measured in seconds and tells your DNS client how long to cache the DNS record as a safeguard against clients holding on to DNS records whose IP addresses might have changed.
  9. To open your computer’s Hosts file, run Notepad as administrator. Easiest way is to press and then type notepad in windows 8 splashscreen, select notepad and right click and then select "Run as administrator" in bottom taskbar area of windows 8. In the Open dialog box, navigate toC:\Windows\System32\Drivers\Etc. In the File type drop-down list, click All Files. Double-click the hosts file to open it.
  10. You should now have a hosts file open with various settings.
  11. After the last line in the file, type 193.61.191.104 university, and then save the file and exit Notepad.
  12. At the command prompt, type ipconfig /displaydns and press Enter to see that the entry is in your DNS cache.
  13. Type ping university and press Enter.
  14. Delete the DNS cache again by typing ipconfig /flushdns and press Enter.
  15. Display your DNS cache by typing ipconfig /displaydns and press Enter.
  16. Notice that the university entry remains in the cache because the Hosts file data always stays in the cache.
  17. Type nslookup scisweb.ulster.ac.uk and press Enter.
  18. Your DNS server’s name and IP address are displayed, along with the name and IP address of www.ulster.ac.uk. You use Nslookup to look up a host’s IP address without actually communicating with it.
  19. Type nslookup and press Enter.
  20. You should now have entered Nslookup’s interactive mode. You should see an arrow prompt.
  21. Type www.google.com and press Enter.
  22. Notice that more than one address is returned along with one or more aliases (other names that www.google.com goes by).
  23. Type www.google.com again (or press the up arrow to repeat the last line you typed) and press Enter.
  24. You should see the IP addresses returned in a different order. (If you don’t, keep trying, and the order will change.)
  25. The www.google.com page can be reached by a number of different IP addresses, and the addresses are returned in a different order sothat a different server is used each time, which is called load balancing.
  26. Nslookup is also used to do reverse lookups, in which the IP address is given and the hostname is returned.
  27. If you are ever concerned that your DNS server is not working correctly, you can test it with Nslookup and compare the results of your DNS server with the results from another server, such as Google's.

Working with DNS from the Command Line in Windows (2024)
Top Articles
Latest Posts
Article information

Author: Errol Quitzon

Last Updated:

Views: 5467

Rating: 4.9 / 5 (79 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Errol Quitzon

Birthday: 1993-04-02

Address: 70604 Haley Lane, Port Weldonside, TN 99233-0942

Phone: +9665282866296

Job: Product Retail Agent

Hobby: Computer programming, Horseback riding, Hooping, Dance, Ice skating, Backpacking, Rafting

Introduction: My name is Errol Quitzon, I am a fair, cute, fancy, clean, attractive, sparkling, kind person who loves writing and wants to share my knowledge and understanding with you.