Search code examples
snmpsnmpd

SNMPd opens "random" UDP port besides 161 and 162 to the outside


I would like to use snmp to monitor my localhost and have installed the corresponding package on Ubuntu 18.03 with apt install snmp. Without having changed the default configuration, I have launched the daemon with systemctl start snmpd. After launching the daemon the output of lsof -i -n | grep snmpd is as follows:

snmpd     14668     Debian-snmp   12u  IPv4 13252990      0t0  UDP 127.0.0.1:snmp 
snmpd     14668     Debian-snmp   13u  IPv4 13252988      0t0  UDP *:41898 

I am wondering about the second line of the output as the port has been opened to the outside. Restarting the daemon changes the open port to another (randomized?) high port number. I have been looking up this behaviour a couple of hours and wasn´t able to find any explanation.

Can anybody explain to me whats going on here or how to disable/remove the open port?


Configuration

AgentAdress is configured as follows:

# /etc/snmp/snmpd.conf

# Listen for connections from the local system only
agentAddress  udp:127.0.0.1:161

The daemon has been launched with following options:

# /etc/default/snmp

# snmpd options (use syslog, close stdin/out/err).
SNMPDOPTS='-Lsd -Lf /dev/null -u Debian-snmp -g Debian-snmp -I -smux,mteTrigger,mteTriggerConf -p /run/snmpd.pid'

Output of ps aux | grep snmpd

/usr/sbin/snmpd -Lsd -Lf /dev/null -u Debian-snmp -g Debian-snmp -I -smux mteTrigger mteTriggerConf -f

Solution

  • So, if anybody comes across the same question: The UDP port has been opened by snmp-traps. In order to avoid this behavior, I had to comment out following line in the snmpd.conf:

    /etc/snmp/snmpd.conf
    
    #  ACTIVE MONITORING
                                        #   send SNMPv1  traps
    # !comment this line out!
    # trapsink     localhost public
    

    Read this link for further information: https://sourceforge.net/p/net-snmp/mailman/message/29219475/