vim /etc/snmp/snmptrapd.conf # Example configuration file for snmptrapd # # No traps are handled by default, you must edit this file! # # authCommunity log,execute,net public # traphandle SNMPv2-MIB::coldStart /usr/bin/bin/my_great_script cold createUser Ad123min SHA "Ad123min" AES "Ad123min"
(2)重启服务
1 2 3 4 5
# 启动 SNMP 服务 [root@compute ~]# systemctl start snmpd.service # 开机启动 SNMP 服务 [root@compute ~]# systemctl enable snmpd.service Created symlink from /etc/systemd/system/multi-user.target.wants/snmpd.service to /usr/lib/systemd/system/snmpd.service.
三、放通防火墙策略🐠
1、放通 udp 162 端口
(1)查看防火墙状态,如下所示,防火墙未启动,所以不用放通策略。之后的步骤全部省略。
1 2
[root@compute ~]# firewall-cmd --state not running
(2)查看防火墙状态,如下所示,防火墙正在运行,所以需要放通策略。
1 2
[root@compute ~]# firewall-cmd --state running
(3)显示所有公共区域
1 2 3 4 5 6 7 8 9 10 11 12 13 14
[root@compute ~]# firewall-cmd --list-all public (active) target: default icmp-block-inversion: no interfaces: ens192 sources: services: dhcpv6-client ssh ports: protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules:
<?xml version="1.0" encoding="utf-8"?> <zone> <short>Public</short> <description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description> <service name="ssh"/> <port protocol="udp" port="161"/> <service name="dhcpv6-client"/> </zone>