1.下载net-snmp -5.3.pre4.tar.gz包.
编译,安装
[root@haha net-snmp -5.2.1]# ./configure --prefix=/usr/local/net-snmp -5.2.1
[root@haha net-snmp -5.2.1]#make
[root@haha net-snmp -5.2.1]#make install
2.创建放配置 文件的目录
[root@haha net-snmp -5.2.1]# mkdir /etc/snmp
3.拷贝配置 文件
将解压出来的包中的EXAMPLE.conf拷贝到刚创建的目/etc/snmp 中,并命名为snmpd.conf
[root@haha net-snmp -5.2.1]# cp -R EXAMPLE.conf /etc/snmp /snmpd.conf
4.修改配置 文件
[root@haha net-snmp -5.2.1]# vi /etc/snmp /snmpd.conf
找到如下行,将其改为你想要的字符串,和网络
# sec.name source community
com2sec local localhost COMMUNITY
com2sec mynetwork NETWORK/24 COMMUNITY
例如
com2sec local localhost COMMUNITY
com2sec mynetwork 192.168.1.0/24 abcpublic
注意要用192.168.1.0/24 MS不能用192.168.1.1/24.另外改后要重启snmp 才能生效.
5.开启snmp
[root@haha net-snmp -5.2.1]# /usr/local/net-snmp -5.2.1/sbin/snmpd -Lsd -Lf /dev/null -p /var/run/snmpd -a -c /etc/snmp /snmpd.conf
6.重启.
[root@haha net-snmp -5.2.1]# killall -9 snmpd
root@haha net-snmp -5.2.1]# /usr/local/net-snmp -5.2.1/sbin/snmpd -Lsd -Lf /dev/null -p /var/run/snmpd -a -c /etc/snmp /snmpd.conf
[root@idc ~]# rpm -qa |grep snmp
net-snmp -libs-5.1.2-11.EL4.7
net-snmp -5.1.2-11.EL4.7
如果没有,那么放入linux 安装盘找到snmp 的rpm包进行安装,或者到网上搜索适合自己linux 发行版本的rpm包进行安装
如果提示有依赖关系,那么通过yum install net-snmp -5.3.1…….rpm来安装。
2、snmpd.conf文件配置
按照如下方式修改snmpd.conf文件
A、修改默认的community string
com2sec notConfigUser default public
将public修改为你才知道的字符串
B、把下面的#号去掉(是干什么用的还没找到答案)
#view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
C、下面列出的是可以访问的oid,比如.1.3.6.1.2.1.1表示可以访问sys组的信息
# Make at least snmpwalk -v 1 localhost -c public system fast again.
# name incl/excl subtree mask(optional)
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1
view systemview included .1.3.6.1.2.1.2
view systemview included .1.3.6.1.2.1.4
D、把下面的语句
access notConfigGroup "" any noauth exact systemview none none
改成:
access notConfigGroup "" any noauth exact mib2 none none
是为了禁止对mib2的访问
3、重启snmpd服务
#/etc/rc.d/init.d/snmpd restart
或#service snmpd restart
完成snmpd的配置
4、确保linux 的iptables防火墙 对我们的流量监控服务器 开放了udp 161端口的访问权限
可使用iptables –L –n 查看当前iptables规则
可编辑/etc/sysconfig/iptables文件来修改iptables规则。
[转自hongliangpan]
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7201003/viewspace-592442/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/7201003/viewspace-592442/