首页 > 解决方案 > 如何防止 snmpd 监听 161 端口?

问题描述

我试图强制 snmpd 监听端口 1610(而不是默认端口 161)。

当我打开调试时,看起来 snmpd 除了我指定的任何其他代理地址外,还坚持侦听端口 161。

我在 Ubuntu 上运行 net-snmp 5.7.2。

这是我的 snmpd.conf:

agentaddress dtlsudp:localhost:1610
agentuser root
agentgroup root

这是我启动 snmpd 的方式: snmpd -f -r -DALL -c snmpd.conf

我可以看到 snmpd 解析配置文件并识别所需的端口 1610,但它也尝试侦听端口 161!

read_config:parser: Found a parser.  Calling it: agentaddress / dtlsudp:localhost:1610
snmpd_ports: port spec: udp:127.0.0.1:161,udp:localhost:1610,dtlsudp:localhost:1610,udp:localhost:1610,dtlsudp:localhost:1610
netsnmp_ds_set_string: Setting APP:2 = "udp:127.0.0.1:161,udp:localhost:1610,dtlsudp:localhost:1610,udp:localhost:1610,dtlsudp:localhost:1610"
snmp_agent: final port spec: "udp:127.0.0.1:161,udp:localhost:1610,dtlsudp:localhost:1610,udp:localhost:1610,dtlsudp:localhost:1610"

如何防止 snmpd 监听 161 端口???

任何帮助表示赞赏。

标签: configurationsnmpnet-snmp

解决方案


我发现它snmpd总是读取 /etc/snmp/snmpd.conf 除非您使用该-C选项明确禁用它。

以下命令有效。它只读取我的本地配置文件。

snmpd -f -DALL -C -c snmpd.conf

推荐阅读