The services file located in %windir%\system32\drivers\etc (which translates to C:\Windows\System32\drivers\etc in most cases) is not related to Windows Services that you manage in the Services control panel (services.msc).
Instead, the services file is a simple text file that maps service names to their corresponding port numbers and protocol types. It's a legacy file dating back to the early days of the Internet and is primarily used by network applications to determine which port to use when communicating with a particular service.
Here's a breakdown of what it does and why it's important:
-
Service Name to Port/Protocol Mapping: The file defines well-known services (e.g., ftp, ssh, http) and associates them with specific TCP and/or UDP ports. For example, you might see entries like:
ftp 21/tcp
ssh 22/tcp
http 80/tcp
https 443/tcp
-
Purpose: When a program needs to communicate with a service (say, an FTP server), it can use the services file (or a system API call that consults this file) to look up the standard port number for FTP (21) and the protocol (TCP). This avoids hardcoding the port number directly into the application. While many applications now use DNS to discover services via SRV records, the services file provides a fallback and a source of standard mappings.
-
How it's used: Applications typically don't directly read this file. Instead, they use operating system functions (like getservbyname() in C/C++) that consult the services file and return the appropriate port number and protocol. This provides a level of abstraction and allows the mappings to be updated centrally without requiring changes to individual applications.
-
Who maintains it? The Internet Assigned Numbers Authority (IANA) maintains a list of assigned port numbers. System administrators can also modify the services file to add custom mappings for local or private services.
-
Importance Today: While DNS SRV records are now often preferred for service discovery, the services file remains important for several reasons:
- Legacy compatibility: Many older applications rely on it.
- Fallback mechanism: It provides a fallback if DNS resolution fails.
- Standard service mappings: It ensures that applications use the standard port numbers for well-known services.
- Local overrides: It allows system administrators to override the default mappings for local services.
-
Not Executable: Importantly, it's a text file. It's not a program or driver. It cannot be executed.
In summary: The services file is a simple text file that maps service names to port numbers and protocols. It's a legacy file that's still used by some applications and operating systems to determine the standard port to use when communicating with a particular service. It is not related to the Windows Services management interface or the execution of services. Don't confuse it with actual service executables.