Centos7.9下的snmp搭建及实例
1.测试环境
在VMware上安装两台Centos7系统,一台作为SNMP NMS(IP:192.168.10.131),一台作为:SNMP Agent(IP:192.168.10.245),分别在其系统上安装snmp服务
2.基础环境配置
为了防止防火墙及selinux等的影响,需关闭防火墙及selinux等,具体参考:
Linux常规基础配置_linux基础配置-CSDN博客
3.安装snmp
yum源配置,具体参考:
Linux常规基础配置_linux基础配置-CSDN博客
3.1.SNMP NMS端安装snmp
snmp安装命令:
yum install -y net-snmp net-snmp-utils
[root@logstash ~]# yum install -y net-snmp net-snmp-utils
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Package matching 1:net-snmp-5.7.2-49.el7.x86_64 already installed. Checking for update.
Package matching 1:net-snmp-utils-5.7.2-49.el7.x86_64 already installed. Checking for update.
Nothing to do
[root@logstash ~]#
[root@logstash ~]# snmpd -v
NET-SNMP version: 5.7.2
Web: http://www.net-snmp.org/
Email: net-snmp-coders@lists.sourceforge.net
[root@logstash ~]#
3.2.SNMP Agent端安装snmp
snmp安装命令:
yum install -y net-snmp net-snmp-utils
[root@kibana ~]# yum install -y net-snmp net-snmp-utils
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: d2lzkl7pfhq30w.cloudfront.net
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
软件包 1:net-snmp-5.7.2-49.el7_9.4.x86_64 已安装并且是最新版本
软件包 1:net-snmp-utils-5.7.2-49.el7_9.4.x86_64 已安装并且是最新版本
无须任何处理
[root@kibana ~]#
[root@kibana ~]# snmpd -v
NET-SNMP version: 5.7.2
Web: http://www.net-snmp.org/
Email: net-snmp-coders@lists.sourceforge.net
[root@kibana ~]#
4.配置snmp
4.1.SNMP NMS端安装snmp
1.进入/etc/snmp目录
2.编辑snmpd.conf文件,并保存
#启用社区信息,只允许本主机访问该节点
com2sec notConfigUser localhost public
com2sec notConfigUser 192.168.10.131 public
#把用户加入安全组
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
#可以查看.1下所有OID的对象信息
view all included .1 80
#允许可读权限
access notConfigGroup "" any noauth exact all none none
3.启动snmp
命令:
systemctl start snmpd
[root@logstash snmp]# systemctl start snmpd
[root@logstash snmp]# systemctl status snmpd
● snmpd.service - Simple Network Management Protocol (SNMP) Daemon.
Loaded: loaded (/usr/lib/systemd/system/snmpd.service; disabled; vendor preset: disabled)
Active: active (running) since Fri 2024-08-23 15:07:17 CST; 55min ago
Main PID: 12381 (snmpd)
Tasks: 1
Memory: 5.2M
CGroup: /system.slice/snmpd.service
└─12381 /usr/sbin/snmpd -LS0-6d -f
Aug 23 15:07:16 logstash systemd[1]: Starting Simple Network Management Protocol (SNMP) Daemon....
Aug 23 15:07:17 logstash systemd[1]: Started Simp