Centos 6.5 SNMP客戶端安裝及配置
SNMP版本:net-snmp-5.7.3.tar.gz
1.下載軟件
cd /usr/local/src
yum -y install gcc
wget http://nchc.dl.sourceforge.net/project/net-snmp/net-snmp/5.7.3/net-snmp-5.7.3.tar.gz
2.解壓編譯安裝
tar -zxvf net-snmp-5.7.3.tar.gz
cd net-snmp-5.7.3
./configure --with-default-snmp-version="2" --with-sys-contact="zjqs" --with-sys-location="XSIDC" --with-logfile="/var/log/snmpd.log" --with-persistent-directory="/opt/net-snmp"
make
make install
4.配置
/usr/local/sbin/snmpd
/usr/local/sbin/snmpd會在/opt/下生成/opt/net-snmpd/snmpd.conf
cd /opt/net-snmpd/
vim snmpd.conf
添加以下內容
com2sec notConfigUser default public
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
view all included .1
access notConfigGroup "" any noauth exact all none none
syslocation www.osyunwei.com
注釋說明
public為團體號
syslocation 為位置
啟動snmpd
cd /opt/net-snmpd
/usr/local/sbin/snmpd -c snmpd.conf
編譯防火牆策略
vim /etc/sysconfig/iptables 添加以下內容
-A INPUT -m udp -p udp --dport 161 -j ACCEPT
重啟防火牆
service iptables restart
腳本一鍵安裝
#!/bin/bash
cd /usr/local/src
yum -y install gcc
wget http://nchc.dl.sourceforge.net/project/net-snmp/net-snmp/5.7.3/net-snmp-5.7.3.tar.gz
tar -zxvf net-snmp-5.7.3.tar.gz
cd net-snmp-5.7.3
./configure --with-default-snmp-version="2" --with-sys-contact="zjqs" --with-sys-location="XSIDC" --with-logfile="/var/log/snmpd.log" --with-persistent-directory="/opt/net-snmp"
make
make install
/usr/local/sbin/snmpd
cd /opt/net-snmpd/
echo "com2sec notConfigUser default public">snmpd.conf
echo "group notConfigGroup v1 notConfigUser">>snmpd.conf
echo "group notConfigGroup v2c notConfigUser">>snmpd.conf
echo "view all included .1">>snmpd.conf
echo "access notConfigGroup "" any noauth exact all none none">>snmpd.conf
echo "syslocation www.osyunwei.com">>snmpd.conf
/usr/local/sbin/snmpd -c snmpd.conf
echo "-A INPUT -m udp -p udp --dport 161 -j ACCEPT">>/etc/sysconfig/iptables
備注:推薦更改一下團體號