Port 162 (SNMP Trap)

Port 162 is the port on which a monitoring system receives SNMP alerts (Traps and Informs) that devices send on their own when something changes, over UDP.

Key facts

Port
162
Protocols
UDP
Range
System port (Well-Known), 0-1023
IANA service name
snmptrap

IANA assigns ports in this range to well-known services, under RFC 6335.

About port 162

Port 162 is the port on which a monitoring system receives SNMP alerts (Traps and Informs) that devices send on their own when something changes, over UDP. Unlike port 161, which is open on the monitored device, port 162 is open on the monitoring system.

RFC 3417 assigns port 162 to receiving SNMP alerts, and the alert types are defined in RFC 3416. In the IANA port registry, port 162 is registered for the snmptrap service.

What port 162 is used for

  • Alerts from network equipment: switches and routers report an interface that went down, a restart, or a power supply failure.
  • UPS units and storage devices: the device reports right away when it switches to battery or when a disk fails.
  • Collecting alerts: the snmptrapd service, or the monitoring system itself, receives the alerts and passes them on to a log, to email, or to the alerting system.

Alerts complement regular monitoring: the monitoring system keeps reading data on port 161, and alerts let you know about an event the moment it happens.

Port 162 in the firewall

Open port 162 only on the monitoring server, and only to the addresses of the devices that send alerts. The devices themselves don't need the port open:

  • UFW: ufw allow from 10.0.0.0/24 to any port 162 proto udp
  • firewalld: firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.0.0/24" port port="162" protocol="udp" accept'

Risks and security

In versions 1 and 2c, an alert is identified only by the Community String, which travels unencrypted, so alerts can be forged to flood the monitoring system. A few simple settings narrow that down:

  • Accept alerts only from the devices' addresses, in the firewall and in the service settings.
  • Prefer SNMPv3 alerts, with authentication and encryption.
  • Set a long, random Community String for alerts on the devices, different from the one used to read data.

Commands to check and configure

  • ss -ulnp | grep ':162 '

    Checks whether any service is listening for alerts on port 162.

  • systemctl status snmptrapd

    Shows whether the alert-receiving service is running.

  • tcpdump -ni any udp port 162

    Shows the alerts reaching the server in real time (requires root).

  • snmptrap -v2c -c MyTrapCommunity 10.0.0.10 '' 1.3.6.1.6.3.1.1.5.1

    Sends a coldStart test alert to the monitoring server, to check that alerts get through.

  • ufw allow from 10.0.0.0/24 to any port 162 proto udp

    Accepts alerts only from the given device network (UFW).

  • firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.0.0/24" port port="162" protocol="udp" accept'

    Accepts alerts only from the given device network in firewalld. Then run firewall-cmd --reload.

Port 162 in the IANA registry

Port Protocol Service IANA registry description
162 TCP snmptrap SNMPTRAP
162 UDP snmptrap SNMPTRAP

Data source: IANA Service Name and Transport Protocol Port Number Registry (opens in a new tab)

Port 162 FAQ

What's the difference between a Trap and an Inform?

A Trap is sent once, with no acknowledgment, so it can get lost. An Inform requires the monitoring system to confirm it received it, and the device sends it again when the confirmation doesn't arrive.

On which machine do I open port 162?

Open port 162 only on the monitoring server that receives the alerts. The devices that send alerts don't need the port open to incoming traffic, because they only send to it. To read data from the devices, use port 161.

How do I check that SNMP alerts reach the monitoring server?

Run tcpdump -ni any udp port 162 on the monitoring server, and send a test alert from the device or with the snmptrap command. When the alert shows up in tcpdump but not in the monitoring system, the problem is in the service settings, for example the Community String or the permissions.

Do SNMP alerts replace regular monitoring?

No. A Trap can get lost, and a device that goes completely down won't send an alert. That's why the two are combined: the monitoring system reads data on a regular schedule, and alerts report events right away.

Shopping cart

Your cart is emptyYou can start with one of our popular plans.

Site search

Accessibility

Text size
100%
Accessibility statement