专业汉语词典知识平台,分享汉字词语知识、历史文学知识解答!

励北网
励北网

snmptrap命令详解,snmptrap介绍及使用

来源:小易整编  作者:小易  发布时间:2023-03-28 11:30
摘要:snmptrap命令详解,snmptrap介绍及使用如果你是对SNMP完全不了解,或者只想学习如何使用现成的SNMP工具,那你找对了文章,但如果你希望学习SNMP具体协议内容,推荐阅读官方的RFC文档。1.简介SNMP(SimpleNetw...
  • snmptranslate:用于翻译OID,例如我们使用 snmptranslate -Td SNMPv2-MIB::system 可以知道system节点所使用的数字OID,反之亦然。
  • snmptrap:可以向管理端发送trap包,主要用于报警,例如我们可以使用sudo snmptrap -v 2c -c public localhost "cxy" .1.3.6.1.2.1.1 SNMPv2-MIB::sysContact.0 s 'test' 向管理端发送一个trap包,管理端即可直接查获并通知管理员,这就为被管理端提供了一种主动向管理端通讯的机制。另外,可以看到参数中多了一些内容,"cxy"是管理端的用户名,.1.3.6.1.2.1.1是主OID,而后面的则是具体的OID及其内容。
  • snmptrapd:部署在管理端,可以通过修改/etc/snmp/snmptrapd.conf来配置其认证方式,一般使用命令sudo snmptrapd -df -Lo 启动该服务,可以通过检查162端口确认其启动。

4.2. MIB-Browser

你可以在官网下载地址http://www.ireasoning.com/download.shtml处获取该应用,由于是图形化界面,所以使用极为简单,下图是SNMP工具的主界面。

snmptrap命令详解,snmptrap介绍及使用

当然,你还可以在Tools中找到Trap Reciever与Trap Sender,其分别对应snmptrapd与snmptrap。

5. Q&A

  1. 获取信息时出现超时或被拒绝 你应该检查snmpd.conf文件的community是否和你命令的-c选项对应,或者是否监听端口是否对所有IP开放,但更多的时候是因为防火墙的原因,只要关掉就好了。
  2. snmpset时出现无权限的问题 需要设置snmpd.conf文件中的rwcommunity。
  3. snmptrap失败 查看snmptrapd.conf文件的配置。这里推荐大家关注公众号:网络技术干货圈,每天都会发布网络技术方面的文章。
  4. OID查找不到的情况 需要下载snmp-mibs-downloader包,并且将/etc/snmp/snmp.conf中的第一行mib:注释掉。

6. configuration example

下面是我在Ubuntu16.04中的一些关于Net-SNMP的相关配置文件:

/etc/snmp/snmp.conf

# As the snmp packages come without MIB files due to license reasons, loading# of MIBs is disabled by default. If you added the MIBs you can reenable# loading them by commenting out the following line.#mibs :

/etc/snmp/snmpd.conf

## EXAMPLE-trap.conf:#   An example configuration file for configuring the Net-SNMP snmptrapd agent.################################################################################## This file is intended to only be an example.# When the snmptrapd agent starts up, this is where it will look for it.## All lines beginning with a '#' are comments and are intended for you# to read.  All other lines are configuration commands for the agent.## PLEASE: read the snmptrapd.conf(5) manual page as well!##authCommunity log,execute,net private authCommunity log,execute,net public### send mail when get any events#traphandle default /usr/bin/traptoemail -s smtp.qq.com 1484652026@qq.com### send mail when get linkDown#traphandle .1.3.6.1.6.3.1.1.5.3 /usr/bin/traptoemail -s smtp.example.org foobar@example.org

/etc/snmp/snmpd.conf

################################################################################# EXAMPLE.conf:#   An example configuration file for configuring the Net-SNMP agent ('snmpd')#   See the 'snmpd.conf(5)' man page for details##  Some entries are deliberately commented out, and will need to be explicitly activated##################################################################################  AGENT BEHAVIOUR##  Listen for connections from the local system only#agentAddress  udp:127.0.0.1:161#  Listen for connections on all interfaces (both IPv4 *and* IPv6)#agentAddress udp:161,udp6:[::1]:161#################################################################################  SNMPv3 AUTHENTICATION##  Note that these particular settings don't actually belong here.#  They should be copied to the file /var/lib/snmp/snmpd.conf#     and the passwords changed, before being uncommented in that file *only*.#  Then restart the agent#  createUser authOnlyUser  MD5 "remember to change this password"#  createUser authPrivUser  SHA "remember to change this one too"  DES#  createUser internalUser  MD5 "this is only ever used internally, but still change the password"#  If you also change the usernames (which might be sensible),#  then remember to update the other occurances in this example config file to match.#################################################################################  ACCESS CONTROL#                                                 #  system + hrSystem groups only#view   systemonly  included   .1.3.6.1.2.1.1#view   systemonly  included   .1.3.6.1.2.1.25.1view   systemonly  included   .1                                                   #  Full access from the local host#rocommunity public  localhost                                                 #  Default access to basic system info rwcommunity public  default    -V systemonly                                                 #  rocommunity6 is for IPv6 rwcommunity6 public  default   -V systemonly                                                 #  Full access from an example network                                                 #     Adjust this network address to match your local

本文地址:百科问答频道 https://www.neebe.cn/wenda/942213_2.html,易企推百科一个免费的知识分享平台,本站部分文章来网络分享,本着互联网分享的精神,如有涉及到您的权益,请联系我们删除,谢谢!


百科问答
小编:小易整编
相关文章相关阅读
  • Excel中countif函数的使用方法

    Excel中countif函数的使用方法

    Excel中有很多函数,很多都可以为我们大大减少计算的时间,一步就得出结果,很多朋友在使用countif函数时,会出现一些错误导致不成功,我们这就来给你详细讲讲countif函数是应该如何使用的。countif函数的含义...

  • apple id忘记密码后怎么使用电脑重设密码

    apple id忘记密码后怎么使用电脑重设密码

    appleid是我们在苹果手机中很重要的一个账号,有的时候我们可能会忘记appleid的密码,那么接下来小编就教大家怎样在电脑上重新设置appleid的密码。具体如下:1.首先我们打开电脑进入到桌面,找到浏览器图标点击打开。进入到浏览器界面...

  • 房蚁的使用方法

    房蚁的使用方法

    房蚁的使用方法如下操作方法011.关注房蚁022.订阅一下作业区域033.收到委托成功通知,点击查看...

  • 微小v手机使用说明

    微小v手机使用说明

    微小v手机拿到手后,请开机,然后根据我的指导,升级后台软件操作方法011、拿到手机第一步。激活手机功能方法,打开设置-关于手机-找到版本号-狂点十次-出现开发者模式-进入-选择允许模拟定位。关机重启。...

  • 虚拟机关机命令poweroff方法

    虚拟机关机命令poweroff方法

    虚拟机是虚拟技术。许多用户将使用虚拟机上的命令自定义操作关机,使其方便快速,有更多的时间来处理其他事情,然后没有其他更容易的Poweroff应该不是命令?让我们来看看。虚拟机命令Poweroff方法首先,Poweroff.1,Powerof...

  • 机箱风扇接口接的位置介绍

    机箱风扇接口接的位置介绍

    电脑使用长时间主机会堆积很多灰尘,特别是主机风扇转动,灰尘是很多的,有的会p电脑的网友就会自己购买新风扇来更换安装新风扇,可是问题就出来了,找不到风扇的接口,那么机箱风扇接口接哪里呢?说的这里其实对于不熟悉电路的网友可能还不清楚机箱的内部结...

  • 我的世界鞘翅怎么获得?鞘翅怎么使用?

    我的世界鞘翅怎么获得?鞘翅怎么使用?

    我的世界1.94版本增加了鞘翅的道具,很多人不知道鞘翅是干什么用的,而且鞘翅因为获得方式比较特殊,以至于很多人都没有见过。下面我就详细的告诉大家如何得到鞘翅,并且告诉大家鞘翅的使用方法。操作方法01首...

  • 曹操专车怎么打车 如何使用曹操专车打车出行

    曹操专车怎么打车 如何使用曹操专车打车出行

    曹操专车怎么打车可能是很多朋友关心的问题,为此小编专门写一篇来未大家分享下打车的方法,希望对你有所帮助。操作方法01首先需要下载一个曹操专车软件,下载并安装好之后,点击软件图标进入到软件首页。进入首页...

  • 周排行
  • 月排行
  • 年排行

精彩推荐