> ## Documentation Index
> Fetch the complete documentation index at: https://doc.lwops.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 1.1.2Linux系统

# 1.1.2. Linux系统

1、安装SNMP

```text theme={null}
# yum install -y net-snmp*
```

2、备份SNMP配置

```text theme={null}
# cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.bak
```

3、添加文本

```text theme={null}
> /etc/snmp/snmpd.conf ; cat > /etc/snmp/snmpd.conf< (configure /etc/snmp/snmp.local.conf)
dontLogTCPWrappersConnects yes
EOF
```

注：rocommunity：允许IP根据团体名以只读方式获取SNMP数据,格式为：rocommunity 团体名 乐维采集服务器IP地址(不填默认为允许全部) 例：rocommunity SZ-SNMP-PRIVATE 10.245.119.44

4、重启SNMP

```text theme={null}
# systemctl restart snmpd
```

5、检查防火墙策略是关闭还是开启，如果开启则添加以下策略 （1）iptables（service iptables status查看状态）

```text theme={null}
# iptables -A INPUT -p udp -m state --state -m udp --dport 161 -j ACCEPT
# service iptables save
```

![1.1.2Linux系统 操作截图 1](https://lwweb.oss-cn-shenzhen.aliyuncs.com/docs/images/yuque/linuxsnmp/image-01.png)

（2）firewalld（service firewalld status查看状态）

```text theme={null}
# firewall-cmd --zone=public --add-port=161/udp --permanent
# firewall-cmd --reload
```

![1.1.2Linux系统 操作截图 2](https://lwweb.oss-cn-shenzhen.aliyuncs.com/docs/images/yuque/linuxsnmp/image-02.png)
