Linux snmpd 未在 Ubuntu 服务器上侦听端口 161
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10168665/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
snmpd is not listening on port 161 on Ubuntu server
提问by user612308
I have installed snmpd on my Ubuntu server via apt-get install snmpd snmp. Then I changed the line in /etc/default/snmpd
我已经通过apt-get install snmpd snmp在我的 Ubuntu 服务器上安装了 snmpd。然后我更改了 /etc/default/snmpd 中的行
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid 0.0.0.0'
After that, I restarted the snmpd server(/etc/init.d/snmpd restart). However, when I ran netstat -an | grep "LISTEN ", I don't see snmpd is listening on port 161.
之后,我重新启动了 snmpd 服务器(/etc/init.d/snmpd restart)。但是,当我运行netstat -an | grep "LISTEN",我没有看到 snmpd 正在侦听端口 161。
I don't have any firewall which blocks that port.
我没有阻止该端口的任何防火墙。
$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
回答by Jim Garrison
Looks like it islistening on 161/UDP. From the man page:
看起来它正在侦听 161/UDP。从手册页:
By default, snmpd listens for incoming SNMP requests on UDP port 161 on all IPv4 interfaces. However, it is possible to modify this behaviour by specifying one or more listening addresses as arguments to snmpd. A listening address takes the form:
[<transport-specifier>:]<transport-address>
默认情况下,snmpd 在所有 IPv4 接口上的 UDP 端口 161 上侦听传入的 SNMP 请求。但是,可以通过将一个或多个侦听地址指定为 snmpd 的参数来修改此行为。侦听地址采用以下形式:
[<transport-specifier>:]<transport-address>
Read the man page for more details
阅读手册页了解更多详情
回答by Douglas Manley
User "nos" is correct; UDP bindings do not show up as "LISTEN" under "netstat". Instead, you will see a line or two like the following, showing that "snmpd" is indeed ready to receive data on UDP port 161:
用户“nos”是正确的;UDP 绑定不会在“netstat”下显示为“LISTEN”。相反,您将看到如下所示的一两行,表明“snmpd”确实已准备好在 UDP 端口 161 上接收数据:
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
udp 0 0 0.0.0.0:161 0.0.0.0:* 1785/snmpd
udp6 0 0 ::1:161 :::* 1785/snmpd
The "netstat" manpage has this to say about the "State" column:
“netstat”联机帮助页有关于“State”列的说明:
The state of the socket. Since there are no states in raw mode and usually no states used in UDP, this column may be left blank.
套接字的状态。由于原始模式中没有状态,UDP 中通常也没有使用状态,因此该列可以留空。
Thus, you would not expect to see the word "LISTEN" here.
因此,您不会期望在此处看到“聆听”一词。
From a practical perspective, however, there is one more thing that I'd like to note. Often, the default Net-SNMP "snmpd.conf" configuration file limits incoming connections to only local processes.
然而,从实践的角度来看,我还要注意一件事。通常,默认的 Net-SNMP“snmpd.conf”配置文件将传入连接限制为仅本地进程。
Default /etc/snmp/snmpd.conf
默认 /etc/snmp/snmpd.conf
# Listen for connections from the local system only
agentAddress udp:127.0.0.1:161
# Listen for connections on all interfaces (both IPv4 *and* IPv6)
#agentAddress udp:161,udp6:[::1]:161,tcp:161,tcp6:[::1]:161
Usually, the point of setting up "snmpd" is so that anothermachine can monitor it. To accomplish this, make sure that the first line is commented out and that the second line is enabled.
通常,设置“snmpd”的目的是让另一台机器可以监视它。为此,请确保注释掉第一行并启用第二行。