FolderRisk: Caution
etc C:\Windows\System32\drivers\etc
C:\Windows\System32\drivers\etc: plain-text network files inherited from Unix: hosts (local resolution), services, protocol, networks and a sample lmhosts.sam.
What it’s for
drivers\etc holds the plain-text network configuration files that Windows inherited from Unix. Only one really matters to an administrator: hosts, which Windows reads before it queries DNS. The others are mostly directories of names and numbers, and the TCP/IP stack does not depend on them.
What it contains
hosts: host name to IP address mappings. Lines starting with#are comments, and the default file has no active entry.services: service names and port numbers.protocol: IP protocol names and numbers.networks: network names. Each has its own page.lmhosts.sam: a sample LMHOSTS file for NetBIOS name resolution.
Risks and best practices
hostsis the classic malware target, which redirects sites to malicious servers there. When network behavior looks odd, it is the first file to open.- To edit it, run an editor as administrator, keep a copy (
hosts.bak) and comment lines out rather than deleting them. A stale entry causes connection errors that are hard to diagnose. - To go back to the original, save the default
hostsfile that Microsoft publishes, rename the current one tohosts.old, then copy the new one into the folder.
Useful commands
# Files in the folder, with their modification dateGet-ChildItem "$env:windir\System32\drivers\etc" -Force | Select-Object Name, Length, LastWriteTime
# Active lines of the hosts file (excluding comments and blank lines)Get-Content "$env:windir\System32\drivers\etc\hosts" | Where-Object { $_.Trim() -and $_ -notmatch '^\s*#' }
# Flush the DNS cache after changing hostsipconfig /flushdnsFolder contents
Files 5
- hostsText file of host name to IP address entries that Windows reads before DNS; used for…
- lmhosts.samSample (.sam) file for LMHOSTS, which maps NetBIOS names to IP addresses; it has no…
- networksUnix-inherited text file mapping names to IP network addresses; rarely used and typically…
- protocolprotocol: text file mapping an IP protocol name to its number (tcp 6, udp 17, icmp 1)…
- servicesText file mapping network service names to port numbers and protocols (for example http…