Chinaunix首页 | 论坛 | 博客
  • 博客访问: 12443
  • 博文数量: 5
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 30
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-22 17:31
文章分类
文章存档

2014年(1)

2012年(4)

我的朋友

分类: LINUX

2014-06-11 11:15:00

公司最近在做电子标签的项目
在选择技术方案时用到了snmp服务功能故产生了该文档

关于net-snmp
维基百科简介:

安装配置共分以下几步
1.获取源文件
2.解压缩
3.配置configure参数
4.编译安装
5.配置snmpd.conf文件
6.设置环境变量
7.添加自启动脚本
8.启动snmp服务
9.测试snmp服务


第一步:
获取源文件
wget

第二步:
解压缩
gunzip net-snmp-5.3.3.tar.gz
tar -xvf net-snmp-5.3.3.tar

第三步:
配置configure参数
cd net-snmp-5.3.3
./configure --prefix=/usr/local/net-snmp --enable-mfd-rewrites --with-default-snmp-version="2" --with-sys-location="China" --with-sys-contact="Email:songyunkui@kingsoft.com" --with-logfile="/usr/local/net-snmp/log/snmpd.log"  --with-persistent-directory="/var/net-snmp"
--ps:参数包括了 将要安装的文件路径 允许用新的重写可用的模块 默认的版本 设备的地址信息 设备的联系人信息 日志文件 永久数据存放目录
温馨提示:在这里如果我们不指定版本、设备地址、设备联系人、log文件及永久数据目录的话那么在接下来的配置时会让我们进行交互选择,刚开始安装时这几个选项把我整蒙了
配置最后(大概一分钟左右)会生成configure的摘要信息,也许会有warning不过不用理他
---------------------------------------------------------
            Net-SNMP configuration summary:
---------------------------------------------------------

  SNMP Versions Supported:    1 2c 3
  Net-SNMP Version:           5.3.3
  Building for:               linux
  Network transport support:  Callback Unix TCP UDP
  SNMPv3 Security Modules:    usm
  Agent MIB code:             mibII ucd_snmp snmpv3mibs notification notification-log-mib target agent_mibs agentx disman/event-mib disman/schedule utilities host
  SNMP Perl modules:          disabled
  Embedded perl support:      disabled
  Authentication support:     MD5 SHA1
  Encryption support:         DES AES
  WARNING:  New version of the Event MIB which may be subtly different from the original implementation - configure with 'disman/old-event-mib' for the previous version


---------------------------------------------------------

第四步:
编译并安装
make && make install
这个会稍微花点时间也就3-5分钟吧


第五步:
配置snmp.conf文件
首先我们把源文件中的EXAMPLE.conf文件复制到/usr/local/net-snmp/share/snmp目录下并命名为snmp.conf
cp EXAMPLE.conf /usr/local/net-snmp/share/snmp/snmp.conf ##这个命令大家应该都懂的

编辑snmp.conf文件
找到
#       sec.name  source          community 这个配置项
#(sec.name:安全体名称 
#source:定义请求的来源,在IP协议中,这个数据是IP地址。在net-snmp中用来对来源IP加以控制,但这个特性不是SNMP规定的,是net-snmp扩展的 .
#community:共同体名称 )
#原来的
com2sec local     localhost       COMMUNITY
com2sec mynetwork NETWORK/24      COMMUNITY

#修改后的
com2sec local     localhost       public
com2sec mynetwork 192.168.8.30   public
com2sec mynetwork 192.168.11.29   public


第六步:
设置net-snmp的环境变量
设置环境变量 在/etc/profile文件下追加
PATH=/usr/local/net-snmp/bin:/usr/local/net-snmp/sbin:$PATH
export PATH

第七步:
添加到启动文件
在/etc/rc.local文件末尾追加
/usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmp/snmpd.conf&

第八步:
重新启动net-snmp服务
/usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmp/snmp.conf&

第九步:
测试
本地通过localhost访问
[root@localhost snmp]# snmpwalk -v 2c -c public localhost if
IF-MIB::ifIndex.1 = INTEGER: 1
IF-MIB::ifIndex.3 = INTEGER: 3
IF-MIB::ifIndex.4 = INTEGER: 4
IF-MIB::ifIndex.5 = INTEGER: 5
IF-MIB::ifIndex.6 = INTEGER: 6
IF-MIB::ifDescr.1 = STRING: lo
IF-MIB::ifDescr.3 = STRING: eth0
IF-MIB::ifDescr.4 = STRING: eth1
IF-MIB::ifDescr.5 = STRING: sit0
IF-MIB::ifDescr.6 = STRING: usb0
本地通过ip访问
[root@localhost snmp]# snmpwalk -v 2c -c public 192.168.8.30 if
IF-MIB::ifIndex.1 = INTEGER: 1
IF-MIB::ifIndex.3 = INTEGER: 3
IF-MIB::ifIndex.4 = INTEGER: 4
IF-MIB::ifIndex.5 = INTEGER: 5
IF-MIB::ifIndex.6 = INTEGER: 6
IF-MIB::ifDescr.1 = STRING: lo
IF-MIB::ifDescr.3 = STRING: eth0
IF-MIB::ifDescr.4 = STRING: eth1
IF-MIB::ifDescr.5 = STRING: sit0
IF-MIB::ifDescr.6 = STRING: usb0
IF-MIB::ifType.1 = INTEGER: softwareLoopback(24)
IF-MIB::ifType.3 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.4 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.5 = INTEGER: tunnel(131)

参考文档:

阅读(1302) | 评论(0) | 转发(0) |
0

上一篇:(转载)vsftpd配置详解(上)

下一篇:没有了

给主人留下些什么吧!~~