[英]How to change the net-snmp default port to one less than 1024 in linux?
[英]How to change the net-snmp trap sender port in linux?
我正在使用net-snmp来收集linux中的系统信息。 但我发现有问题。
当我通过netstat检查Net-SNMP的端口使用情况时,我发现使用3个UDP端口的net-snmp。
这是结果。
[root@ snmp]# netstat -anp | grep snmp
tcp 0 0 127.0.0.1:199 0.0.0.0:* LISTEN 6392/snmpd
udp 0 0 0.0.0.0:49005 0.0.0.0:* 6392/snmpd
udp 0 0 0.0.0.0:161 0.0.0.0:* 6392/snmpd
udp 0 0 0.0.0.0:44837 0.0.0.0:* 6392/snmpd
如您所见,snmpd使用了另外两个不带161的udp端口。我也发现了为什么2个udp端口被snmp随机占用。
这些端口用于发送snmp陷阱。 当我删除tran2sink和notifysink选项时,不再显示2个UDP端口。
这是我配置snmpd.conf的一部分
###########################################################################
# SECTION: Trap Destinations
#
# Here we define who the agent will send traps to.
# trap2sink: A SNMPv2c trap receiver
# arguments: host [community] [portnum]
trap2sink 192.168.1.4
# informsink: A SNMPv2c inform (acknowledged trap) receiver
# arguments: host [community] [portnum]
informsink 192.168.1.4 NMS_COM
# trapcommunity: Default trap sink community to use
# arguments: community-string
trapcommunity NMS_COM
# authtrapenable: Should we send traps when authentication failures occur
# arguments: 1 | 2 (1 = yes, 2 = no)
authtrapenable 1
我的程序必须使用40000〜50000 udp端口。 所以我想使用这些陷阱选项并更改端口。
如何修复端口?
您可以尝试为指令设置端口,如下所示:
trap2sink 1.1.1.1:port_num例如trap2sink 1.1.1.1:162
希望我理解您的问题,对您有所帮助。
这些是SNMP临时端口。 这是来自Microsoft支持页面上的报价:
在SNMP服务运行时,可以通过netstat命令行实用程序注意到,除了众所周知的用于发送和接收SNMP陷阱的端口(161/162)外,该服务还创建了一个随机临时端口。
随机端口的使用是预期的行为,并且为了发送“管理”陷阱而打开
...
SNMP服务运行时,此端口将保留在系统中,但是除非将管理陷阱发送到外部,否则该端口不会被有效使用。 由于SNMP不会在此随机端口上侦听入站数据包,因此不会出现安全漏洞。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.