自适应安全设备(ASA)
ASDM
命令行界面
# SNMPv2c
snmp-server community
snmp-server contact
snmp-server location
snmp-server host poll community version 2c
# SNMPv3
snmp-server group v3 priv
snmp-server user v3 auth sha priv aes 128
snmp-server contact
snmp-server location
snmp-server host poll version 3
注意:如果设备无法找到SNMP用户,请重新启动ASA。重新启动后,请照常继续执行步骤。
iOS / IOS XE
# SNMPv2c
snmp-server community RO
snmp-server contact
snmp-server location
# SNMPv3
snmp-server group v3 priv
snmp-server user v3 auth sha priv aes 128
snmp-server contact
snmp-server location
# Note: The following is also required if using SNMPv3 and you want to populate the FDB table.
snmp-server group v3 priv context vlan- match prefix
注意:如果设备无法找到SNMP用户,请重新启动ASA。重新启动后,请照常继续执行步骤。
NX-OS
# SNMPv2c
snmp-server community RO
snmp-server contact
snmp-server location
# SNMPv3
snmp-server user v3 auth sha priv aes 128
snmp-server contact
snmp-server location
无线局域网控制器(WLC)
网卡-MS
通知OS 3.2.x
addsnmpmgr
setsnmppw
NIOS 7.x +
Junos操作系统
用于SNMPv1 / v2c
set snmp description description
set snmp location location
set snmp contact contact
set snmp community YOUR-COMMUNITY authorization read-only
对于SNMPv3(authPriv):
set snmp v3 usm local-engine user authpriv authentication-sha authentication-password YOUR_AUTH_SECRET
set snmp v3 usm local-engine user authpriv privacy-aes128 privacy-password YOUR_PRIV_SECRET
set snmp v3 vacm security-to-group security-model usm security-name authpriv group mysnmpv3
set snmp v3 vacm access group mysnmpv3 default-context-prefix security-model any security-level authentication read-view mysnmpv3view
set snmp v3 vacm access group mysnmpv3 default-context-prefix security-model any security-level privacy read-view mysnmpv3view
set snmp view mysnmpv3view oid iso include
RouterOS 6.x
CLI SNMP v2配置
/snmp community
set [ find default=yes ] read-access=no
add addresses= name=
/snmp
set contact="" enabled=yes engine-id= location=""
笔记:
authPriv的 CLI SNMP v3配置
/snmp community
add name="" addresses=""
set "" authentication-password="" authentication-protocol=MD5
set "" encryption-password="" encryption-protocol=AES
set "" read-access=yes write-access=no security=private
#Disable public SNMP
set public read-access=no write-access=no security=private
/snmp
set contact="" enabled=yes engine-id="" location=""
笔记:
SNMP v2和v3的注意事项
/snmp set src-address=
全景图6.x / 7.x
请注意,您需要在所需的接口上允许SNMP。为此,您需要为标准接口创建网络“接口管理”配置文件,并在“设备>管理>管理接口设置”下允许SNMP用于带外管理接口。
也可以从命令行配置SNMP,当您需要为SNMP监视配置多个防火墙时,这很有用。通过ssh登录到防火墙,然后对基本SNMPv3配置执行以下命令:
username@devicename> configure
username@devicename# set deviceconfig system service disable-snmp no
username@devicename# set deviceconfig system snmp-setting access-setting version v3 views pa view iso oid 1.3.6.1
username@devicename# set deviceconfig system snmp-setting access-setting version v3 views pa view iso option include
username@devicename# set deviceconfig system snmp-setting access-setting version v3 views pa view iso mask 0xf0
username@devicename# set deviceconfig system snmp-setting access-setting version v3 users authpriv authpwd YOUR_AUTH_SECRET
username@devicename# set deviceconfig system snmp-setting access-setting version v3 users authpriv privpwd YOUR_PRIV_SECRET
username@devicename# set deviceconfig system snmp-setting access-setting version v3 users authpriv view pa
username@devicename# set deviceconfig system snmp-setting snmp-system location "Yourcity, Yourcountry [60.4,5.31]"
username@devicename# set deviceconfig system snmp-setting snmp-system contact [email protected]
username@devicename# commit
username@devicename# exit
边缘操作系统
如果使用HTTP界面:1.访问旧版Web admin页面并登录1.进入“系统”>“高级配置” 1.进入子选项卡“ SNMP”>“社区” 1.单击“添加社区组” 1 。输入您的SNMP社区,ip地址,然后单击提交1.进入系统>摘要1.进入子标签“描述” 1.输入您的系统名称,系统位置和系统联系人。1.单击提交1.单击“保存配置”
如果使用CLI:
username@devicename> enable
username@devicename# configure
username@devicename (Config)# snmp-server community "public" ro
username@devicename (Config)# snmp-server sysname "devicename"
username@devicename (Config)# snmp-server contact "[email protected]"
username@devicename (Config)# exit
username@devicename# write memory
ESX / ESXi 5.x / 6.x
通过ssh登录到ESX服务器。您可能必须先在GUI中启用ssh服务。从CLI,执行以下命令:
esxcli system snmp set --authentication SHA1
esxcli system snmp set --privacy AES128
esxcli system snmp hash --auth-hash YOUR_AUTH_SECRET --priv-hash YOUR_PRIV_SECRET --raw-secret
该命令产生这样的输出
Authhash: f3d8982fc28e8d1346c26eee49eb2c4a5950c934
Privhash: 0596ab30b315576a4e9f7d7bde65bf49b749e335
现在定义一个SNMPv3用户:
esxcli system snmp set --users /f3d8982fc28e8d1346c26eee49eb2c4a5950c934/0596ab30b315576a4e9f7d7bde65bf49b749e335/priv
esxcli system snmp set -L "Yourcity, Yourcountry [60.4,5.3]"
esxcli system snmp set -C [email protected]
esxcli system snmp set --enable true
注意:
esxcli network firewall set --enabled false
如果发生snmp超时,请使用禁用防火墙。如果在禁用防火墙的情况下仍然发生snmp超时,请根据需要迁移VM并重新启动ESXi主机。
vCenter 6.x
通过ssh登录到ESX服务器。您可能必须先在GUI中启用ssh服务。从CLI,执行以下命令:
snmp.set --authentication SHA1
snmp.set --privacy AES128
snmp.hash --auth_hash YOUR_AUTH_SECRET --priv_hash YOUR_PRIV_SECRET --raw_secret true
该命令产生这样的输出
Privhash: 0596ab30b315576a4e9f7d7bde65bf49b749e335
Authhash: f3d8982fc28e8d1346c26eee49eb2c4a5950c934
现在定义一个SNMPv3用户:
snmp.set --users authpriv/f3d8982fc28e8d1346c26eee49eb2c4a5950c934/0596ab30b315576a4e9f7d7bde65bf49b749e335/priv
snmp.enable
通过以下示例替换snmpd.conf文件,并在“ RANDOMSTRINGGOESHERE”中使用适当的社区对其进行编辑。
vi /etc/snmp/snmpd.conf
# Change RANDOMSTRINGGOESHERE to your preferred SNMP community string
com2sec readonly default RANDOMSTRINGGOESHERE
group MyROGroup v2c readonly
view all included .1 80
access MyROGroup "" any noauth exact all none none
syslocation Rack, Room, Building, City, Country [GPSX,Y]
syscontact Your Name
#Distro Detection
extend .1.3.6.1.4.1.2021.7890.1 distro /usr/bin/distro
#Hardware Detection (uncomment to enable)
#extend .1.3.6.1.4.1.2021.7890.2 hardware '/bin/cat /sys/devices/virtual/dmi/id/product_name'
#extend .1.3.6.1.4.1.2021.7890.3 manufacturer '/bin/cat /sys/devices/virtual/dmi/id/sys_vendor'
#extend .1.3.6.1.4.1.2021.7890.4 serial '/bin/cat /sys/devices/virtual/dmi/id/product_serial'
注意:在某些系统上,snmpd以其自己的用户身份运行,这意味着它无法读取/sys/devices/virtual/dmi/id/product_serial
模式0400。一种解决方案是@reboot chmod 444 /sys/devices/virtual/dmi/id/product_serial
在crontab中包含root或等效名称。
LibreNMS服务器在此处包括此示例的副本:
/opt/librenms/snmpd.conf.example
必须从原始源存储库复制二进制文件/ usr / bin / distro:
curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
chmod +x /usr/bin/distro
转到/etc/snmp/snmpd.conf
在vi或nano /etc/snmp/snmpd.conf中打开文件,并添加以下行以创建SNMPV3用户(用您自己的用户名和密码替换):
createUser authPrivUser MD5 "authPassword" DES "privPassword"
通过在snmpd.conf中添加以下行,确保代理侦听所有接口:
agentAddress udp:161,udp6:[::1]:161
该行仅表示分别监听所有接口IPv4和IPv6的连接
取消注释并更改以下行以授予对上面创建的用户名的读取权限(robre是LibreNMS使用的用户名):
#rouser authPrivUser priv
在snmpd.conf中更改以下详细信息
syslocation Rack, Room, Building, City, Country [GPSX,Y]
syscontact Your Name
保存并退出文件
重新启动snmpd服务
CENTOS 6 / RED HAT 6
service snmpd restart
CENTOS 7 /红帽7
systemctl restart snmpd
将SNMP添加到Firewalld
firewall-cmd --zone=public --permanent --add-service=snmp
firewall-cmd --reload
的UBUNTU
service snmpd restart
注意:使用Net-SNMP可以在Windows平台上支持SNMPv3。
第1步: sudo nano /etc/snmp/snmpd.conf
#Allow read-access with the following SNMP Community String:
rocommunity public
# all other settings are optional but recommended.
# Location of the device
syslocation data centre A
# Human Contact for the device
syscontact SysAdmin
# System Name of the device
sysName SystemName
# the system OID for this device. This is optional but recommended,
# to identify this as a MAC OS system.
sysobjectid 1.3.6.1.4.1.8072.3.2.16
第2步:
sudo launchctl load -w /System/Library/LaunchDaemons/org.net-snmp.snmpd.plist