snmp 設定
安裝過程
yum -y install net-snmp net-snmp-utils
apt install snmpd snmp
mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.org
vim /etc/snmp/snmpd.conf
# this create a SNMPv1/SNMPv2c community named "my_servers"
# and restricts access to LAN adresses 192.168.0.0/16 (last two 0's are ranges)
rocommunity public 192.168.0.0/24
# setup info
syslocation 主機所在地
syscontact 聯絡資訊
# open up
agentAddress udp:161
# run as
agentuser root
# dont log connection from UDP:
dontLogTCPWrappersConnects yes
# fix for disks larger then 2TB
realStorageUnits 0
systemctl start snmpd.service
systemctl enable snmpd.service
systemctl status snmpd.service
netstat -anulp | grep 161
在防火牆增加 161 port 來源沒有限制
firewall-cmd --permanent --add-port=161/udp
success
防火牆立即生效
firewall-cmd --reload
success
檢查看是否有成功增加 161 port
firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: eth0
sources:
services: ssh dhcpv6-client http https
ports: 161/udp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
參考相關網頁