# Overview

Start by reading the snmp_config manual page that describes how the Net-SNMP configuration files operate and how they all work together. Note: When using Windows, all configuration files should be placed in the (install folder)\etc\snmp folder.
Note: The Net-SNMP configuration files generally contain sensitive information such as passphrases and community strings so permissions should be set to restrict who can read the files.
A Perl script called snmpconf is included which can be used to create configuration files. Full documentation on using snmpconf is available in the 'Applications' section.
To run snmpconf, use the following command line:
snmpconf -i

## Environment / registry variables

During compilation of Net-SNMP, the default search path for configuration files is set to a value which under Windows is normally c:/usr/etc/snmp. Similarly the default share path is set to c:/usr/share/snmp. The conf path is used to locate configuration files such as snmp.conf, snmpd.conf etc, and the share path is used by programs such as snmpconf and mib2c to store supporting files.
As explained in the snmp_config manual, the default search path can be changed by modifying the SNMPCONFPATH environment variable. Similarly, the default share path can be set by modifying the SNMPSHAREPATH environment variable.
There are two ways to set Net-SNMP environment variables under Windows. The first way is to simply set the environment variable using the System Control Panel (Advanced tab - Environment variables). The environment variables can be defined as either System or User specific. System is the recommended choice as it allows the variable to be used by all users.
The second and preferred way is to add the environment variables as string values (REG_SZ) to the registry under the HKEY_LOCAL_MACHINE\Software\Net-SNMP or the HKEY_CURRENT_USER\Software\Net-SNMP key. Creating a string value with the environment variable name and assigning a string value to it is equivalent to defining the environment variable. This is a feature of Net-SNMP and not a standard Windows feature. Any environment variable used by Net-SNMP can be defined this way; it is not limited to just SNMPCONFPATH and SNMPSHAREPATH.
For example, if Net-SNMP was compiled to use c:\usr (such as the Windows binary available from the Net-SNMP site), but it was installed in the folder c:\Net-SNMP, then the following environment variables or registry keys must be created so that the applications know where to find the configuration and supporting files:
Method 1: Environment variables:

- SNMPCONFPATH=c:/Net-SNMP/etc/snmp;c:/Net-SNMP/snmp/persist
- SNMPSHAREPATH=c:/Net-SNMP/share/snmp

Method 2: Registry:

- HKEY_LOCAL_MACHINE\Software\Net-SNMP\SNMPCONFPATH=c:/Net-SNMP/etc/snmp;c:/Net-SNMP/snmp/persist
- HKEY_LOCAL_MACHINE\Software\Net-SNMP\SNMPSHAREPATH=c:/Net-SNMP/share/snmp

During the installation of the Windows binary from the Net-SNMP site, the installer automatcially creates the following registry keys:

- HKEY_LOCAL_MACHINE\Software\Net-SNMP\SNMPCONFPATH=(install folder)/etc/snmp;(install folder)/snmp/persist
- HKEY_LOCAL_MACHINE\Software\Net-SNMP\SNMPSHAREPATH=(install folder)/share/snmp

If Net-SNMP is installed in a folder other than the default c:\usr folder, then the above registry keys or environment variables must match, and the snmp.conf file must contain a definition for mibdirs, persistentDir and tempFilePattern. For example, if Net-SNMP was installed in c:\Net-SNMP, the snmp.conf file must contain:
mibdirs c:/net-snmp/share/snmp/mibs
persistentDir c:/net-snmp/snmp/persist
tempFilePattern c:/net-snmp/temp/snmpdXXXXXX

The registry is the recommended method for defining the SNMPCONFPATH and SNMPSHAREPATH variables. Due to a limitation in the Windows Service Control Manager (SCM), if any system environment variables are changed, the system will need to be rebooted to allow the services to access the changed environment variables (see Microsoft knowledge base article 821761). Therefore, when running snmpd or snmptrapd as a service, if SNMPCONFPATH or SNMPSHAREPATH is changed, a reboot will be required after setting the environment variables, otherwise the services may fail to start. Using the registry to store the environment variables eliminates this problem.

Note1: All paths contained in configuration files must use forward slashes (Unix convention), NOT back slashes.

Note2: HKEY_CURRENT_USER can be used instead of HKEY_LOCAL_MACHINE if desired. All applications will search for SNMPCONFPATH and SNMPSHAREPATH (and any other variable normally defined as an environment variable) in the following order:

- Environment space
- HKEY_CURRENT_USER\Software\Net-SNMP\
- HKEY_LOCAL_MACHINE\Software\Net-SNMP\