First, install SNMP1.1, download the source code of NET-SNMP
Select an SNMP version, such as 5.7.1, as follows: HTTP://SOURCEFORGE.NET/PROJECTS/NET-SNMP/FILES/NET-SNMP/5.7.1/, as shown in:
After the download is complete, get a compressed package as shown
1.2. Transfer the compressed package to a remote Linux server
Transfer compressed packets to a remote Linux server using the FTP transfer tool
After the upload is successful, you can see the compressed package in the root directory of Linux, as shown in:
You can also use the LS command in the Linux command-line window to list all files in the root directory for viewing, as shown in:
1.3. Extract the source code package
Use the command "tar xzvf net-snmp-5.7.1.tar.gz" to extract the downloaded source code package, as shown in:
After the extract succeeds, get a net-snmp-5.7.1 folder, as shown in:
1.4. Generate compilation rules by configure
Use the command "CD net-snmp-5.7.1" to enter the net-snmp-5.7.1 directory as shown in:
net-snmp-5.7.1 directory Configure is an executable file, if you want to specify the installation path of the package, then first set up the appropriate folder to hold the installation information, can be written as./configure–-prefix=/the specified path name. The parameter--prefix is used to tell the system where the installation information is stored, and if no path is specified, the package is installed in the default directory of the system, typically:/usr/local
Execute command "./configure--prefix=/usr/local/snmp--with-mib-modules= ' Ucd-snmp/diskio ip-mib/ipv4interfacetable ' ", note that the--with-mib-modules=ucd-snmp/diskio option above allows the server to support disk I/O monitoring. As shown in the following:
Enter the following problem, you can directly enter without answering, the system will take the default information, where the log file is installed by default in/var/log/snmpd.log. The data storage directory is stored by default under/VAR/NET-SNMP
1. Default version Of-snmp-version (3):
2. System Contact information (@ @no. where) (Configure the device's contacts):
3. System location (Unknown) (the geographical position of the device):
4. Location to write logfile (log file position):
5. Location to Write persistent (data storage directory):
1. Default version of-snmp-version:
2. Systemcontact information (contact person to configure the device):
3. System location (where the device is located):
4. Location to write logfile (log file position):/var/log/snmpd.log
5. Location to Write persistent (data storage directory):/VAR/NET-SNMP
1.5. Compiling and installing
Perform the compile and install the make&& make installcommand as shown in:
1.6, Configuration snmpd.conf
Use the "ls" command to see if the ETC directory exists under the/USR/LOCAL/SNMP directory, and if the ETC directory does not exist, create one as shown:
The view results show that there is no etc directory, create a etc directory under the/USR/LOCAL/SNMP directory, create the ETC Directory command "mkdir/usr/local/snmp/etc" as shown in:
Locate the SNMP source directory (net-snmp-5.7.1) under the example.conf file as shown in:
Copy the example.conf file to the/usr/local/snmp/etc directory and rename it to snmpd.conf: "CP example.conf/usr/local/snmp/etc/snmpd.conf "
Open the snmpd.conf file with the VI Editor: "vi/usr/local/snmp/etc/snmpd.conf", edit the contents of the snmpd.conf file
Press the letter "I" or "Insert" key on the keyboard to enter the edit mode of the VI editor
To configure the contents of the snmpd.conf as follows:
1. Configure Allow network access
Locate "AGENT behaviour" as shown in:
Modify the following: Add the "agentaddress udp:161" configuration entry as shown:
2. Select the version of the V2C SNMP protocol
Locate "ACTIVE monitoring" as shown in:
Modify the following:
3. Set access rights
Locate "ACCESS CONTROL" as shown in:
Find "rocommunity public default-v systemonly", put the-v systemonly removed, this is set access permissions, removed after access to all, as shown:
4. Exit after saving snmpd.conf
Press the "ESC" key on the upper left corner of the keyboard to exit the edit mode of the VI editor, then enter the command ": Wq" to save the file and exit as shown:
After the 4 steps above, the configuration of the snmpd.conf file for SNMP is complete.
1.7. Start the SNMP service
Since we have just modified the SNMP snmpd.conf file, use the command "PS aux | grep snmp | grep-v grep |awk ' {print $} ' | Xargs kill" before starting the SNMP service The related services of NMP, as shown in:
Use "netstat-an |grep 161" to see if the SNMP service is started, as shown in:
Start the SNMP service: "/usr/local/snmp/sbin/snmpd-c/usr/local/snmp/etc/snmpd.conf" as shown in:
1.8. Testing SNMP
Get the native system name, using the command: "snmpget-v 2c-c public localhost sysname.0" or "snmpget-v 2c-c public native IP address sysname.0 "or"snmpget-v 2c-c public native IP address. 1.3.6.1.2.1.1.5.0"to test,
Perform the following commands to get the system name to the native:
Snmpget-v 2c-c public localhost sysname.0
Snmpget-v 2c-c public 127.0.0.1 sysname.0
Snmpget-v 2c-c Public 192.168.1.229 sysname.0
Snmpget-v 2c-c public localhost. 1.3.6.1.2.1.1.5.0
Snmpget-v 2c-c public 127.0.0.1.1.3.6.1.2.1.1.5.0
Snmpget-v 2c-c public 192.168.1.229.1.3.6.1.2.1.1.5.0
As shown in the following:
The ability to return the system name correctly indicates that the SNMP installation configuration was successful. You can also use the command "Snmpget--version" to view the current installation version number to verify that the installation was successful, and if the installation is successful, display the current installation version number as shown in:
1.9. Open UDP 161 port access rights
After the SNMPD configuration is complete and the SNMP test passes, ensure that the Linux iptables Firewall is open to access to UDP port 161, and you can use "iptables–l–n" To view the current iptables rules as shown in:
As you can see, the iptables firewall is currently not open to UDP 161 port access, that is, the outside of the computer is unable to access the SNMP service under Linux, you can use the "iptables-i input-p UDP--dport 161-j ACCEPT"command to add the UDP 161 port to the Iptables firewall, and then execute the"iptables save"command to save the firewall changes as shown in:
We can test SNMP access under Linux using the Snmputil.exe tool under the window System and test whether the UDP 161 port of Linux is open to the outside, as shown in:
"Snmputil get 192.168.1.229 public. 1.3.6.1.2.1.1.5.0" The command returns the name of the Linux server 192.168.1.229, and you can see that the name of the Linux server has returned to the command-line window normally.
Second, uninstall SNMP
If you want to uninstall SNMP after installation, you can execute the "make Uninstall" command and uninstall the following steps:
1. Use "Netstat-an |grep 161" To see if the SNMP service is started
2. If you have already started, use the command "PS aux | grep SNMP | grep-v grep |awk ' {print $} ' | Xargs kill "shutdown SNMP related services
3. Enter the SNMP source directory (net-snmp-5.7.1)
4. Execute "make uninstall" command to uninstall SNMP
5, delete the SNMP directory under/usr/local and all the files in the SNMP directory, USR/LOCAL/SNMP is the installation path of SNMP
As shown in the following:
Start uninstalling SNMP as shown in:
The SNMP uninstallation is complete as shown in:
Delete the SNMP directory under/usr/local and all files in the SNMP directory, as shown in:
SNMP Learning Summary (vi) Installing and configuring SNMP under--linux