Install net-snmp5.7.1 in ubuntu

Source: Internet
Author: User
Tags snmpget snmpwalk
Ubuntu install net-snmp571 under Ubuntu install net-snmp, the specific steps are as follows: 1, get net-snmp installation package, here we select the source code installation method, of course you can also choose ubuntu network download method to install, such as: & gt; sudoapt-getinstall ubuntu to install the net-snmp5.7.1 under Ubuntu to install net-snmp, the specific steps are as follows: 1. obtain the net-snmp installation package. Here we select the source code installation method. of course, you can also select the ubuntu network download method for installation, such as:> sudo apt-get install net-snmp ipv2then copy net-snmp-5.7.1.tar.gz to/root. # Tar-zxvf net-snmp-5.7.1.tar.gz # cd net-snmp-5.7.1 3. install the snmp dependency package under Ubuntu as follows:> sudo apt-get install libperl-dev // This step is automatically downloaded, after automatic installation 4. go to the decompressed directory cd net-snmp and start configuration>. /configure -- with-default-snmp-version = "3" -- with-sys-contact = "@ no. where "-- with-sys-location =" Unknown "-- with-logfile ="/var/log/snmpd. log "-- with-persistent-directory ="/var/net-snmp ". /configure -- enable-mfd-rewrites -- enable-embedded- Perl -- with-perl-modules -- with-default-snmp-version = "2" -- with-sys-contact = "linux" -- with-sys-location = "China" configuration after completion, the configuration information is automatically printed. you can see the following configuration information about Net-snmp: --------------------------------------------------------- Net-SNMP configuration summary: ----------------------------------------------------- 5. Compile and install // at this time, you are advised to restart and compile again. otherwise, compilation errors may occur.> sudo make install 6. set any directory to run the snmp, you need to make the following settings: echo expor T LD_LIBRARY_PATH =/usr/local/lib>. bashrc 7. start the snmp process and run snmpd in any directory! You can also/usr/share/sbin/snmpd-c/usr/local/share/snmp/snmpd. conf & // run in the background 8. verify that the installation is successful, as shown below:> snmpget-version if successful, the current installation version is displayed, NET-SNMP version: 5.7.1 if the following error is prompted: snmpget: error while loading shared libraries: libnetsnmp. so.30: cannot open shared object file: No such file or directory: two dynamic library files are missing. Solution: cp/usr/local/lib/libnetsnmpmibs. so.30/usr/lib and cp/usr/local/lib/libnetsnmpmibs. so.30/usr/lib or/us Copy all packages in r/local/lib to/usr/lib. this time, the correct version number is output, indicating that net-snmp is successfully installed in Ubuntu! 9. configure the snmpd. conf file. (Cd/usr/local/share/snmp/, enter snmpconf on the terminal, run snmpconf, and prompt to create three configuration files: snmpd. conf, snmptraps. conf, snmp. conf, and then prompt to move the three files to/usr/local/share/snmp. Manually configure snmpd. conf method: Enter 1, select 2, enter acess control setup, select 3 (set rocommunity to public here), select default, and press enter ., select 4: Agent Operating Mode and enter port 161. You can modify the parameters in vi snmpd. conf .) Configure snmpd. conf file: Enter the source code package directory, cp EXAMPLE. conf/usr/local/share/snmp/, or directly edit and create vi snmpd in the snmp directory. conf file. # Vi/usr/local/share/snmp/snpmd. conf add the following content to the snmpd. conf file, and remove the UDP before the snmpd. conf port. # My configuration file is like this: there are four commands -- com2sec, group, view, access # com2sec: set accessible IP addresses, access passwords, and groups # sec. name source community # specify an accessible IP com2sec local 192.168.0.2 public # group to set the security username group # sec. model sec. name group MyRWGroup v2c local # view which MIB subtree can be accessed # incl/excl subtreemask view all ACLS ded.1 # access specifies the read and write permissions of each group on the MIB # context sec. model sec. level match read write notif access MyRWGroup "" any noauth exact Ll all none 10. check whether the service is successfully started and check port 161 # lsof-I: 161. if the terminal displays 1, the NAME must be displayed * instead of localhost, the service is successfully started. If it is displayed, port 161 is listened on localhost, that is, it is not open to the outside world and can only access local port 161. We should remove this restriction. Access is restricted. Generally, the following method is used to remove the access restriction: 1. edit the route table # sudo iptables-L to view the existing iptables firewall rules. If you set the server in the frame, the rule table should be empty. Display Content: Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination # iptables-a input-p udp-I eth0 -- dport 161-j ACCEPT # sudoiptables-L view the existing iptables firewall rule Chain INPUT (policy ACCEPT) target prot optsource destination ACCEPT udp -- anywhere udpdpt: snmp 2. Save the route table. After the machine is restarted, the configuration information in iptables is cleared. You can save these configurations so that iptables is automatically loaded at startup, saving you the need to re-input each time. # Iptables-save and # iptables-restore are used to save and restore settings. Set the configured route table to automatically load at startup: # iptables-save>/etc/iptables. up. rules // first save the firewall rules to/etc/iptables. up. in the rules File, modify the script vi/etc/network/interfaces so that the system can automatically apply these rules and add the following content. Auto eth0 iface eth0inet dhcp pre-up iptables-restore </etc/iptables. up. rules all completed, restart Ubuntu, check the route table to see if port 161 has exceeded the localhost restriction. 11. run the following command to test whether our agent works properly: (note that the specified version number must be consistent with that of snmpd. the version of the user group configured in conf is the same.) # snmpwalk-v 2c-c public (ip address set above) 1.3.6.1.2.1.1 // (ip address set above) is the IP address to be tested, you can also run # snmpwalk-v 2c-c public 192.168.0.7 1.3.6.1.2.1.1 for another virtual machine on the local machine. // if a pile of MIB information is printed, the configuration is successful. Perform a local test: snmpwalk-v 2c-c public 127.0.0.1 system // This is also available, test whether the service starts snmpwalk-v 2c-c public localhost if // if no snmpwalk command is prompted, apt-get install snmp snmpwalk-v 1-c public localhost. 1.3.6.1.2.1.2.2.1.2 // test the IP address used to obtain information about the system. the IP address is a local IP address or a remote IP address. an output indicates normal snmpwalk-v 2c-c public 192.168.0.14 if snmpwalk-c public-v 2c localhost 12. start the service after it is started, or you can choose not to configure it as a service. Command: gedit/etc/rc. add usr/local/sbin/snmpd-c/usr/local/share/snmp/snmpd before exit 0. conf & 13. disable the snmp service ps aux | grep snmp, obtain the snmp process PID, and then killpid. remember that each time you perform the snmpd operation. to take effect after the conf file is modified, you must kill the old snmp process and then enable the new one. you can also use this service snmpd restart to restart the service. if you encounter snmpd: unrecognizedservice, you only need to update apt-get install snmp snmpd.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.