Port 161 (SNMP)
Key facts
- Port
- 161
- Protocols
- UDP
- Range
- System port (Well-Known), 0-1023
- IANA service name
- snmp
IANA assigns ports in this range to well-known services, under RFC 6335.
About port 161
Port 161 is the port of SNMP (Simple Network Management Protocol), the protocol monitoring systems use to read data from network equipment, servers, and other devices, over UDP. An agent runs on the monitored device and listens on port 161, and the monitoring system sends it queries.
SNMPv3 is defined in the RFC 3411 to RFC 3418 series, and RFC 3417 assigns port 161 to queries sent to the agent. In the IANA port registry, port 161 is registered for the snmp service.
What port 161 is used for
- Traffic graphs: monitoring systems read the traffic counters of routers and switches, and show network usage over time.
- Server monitoring: CPU load, memory, and disk data are read from the agent running on the server.
- Other equipment: printers, UPS units, and storage devices report their status over SNMP.
Alerts a device sends on its own, without a query, go to port 162 on the monitoring system.
Port 161 in the firewall
Open port 161 only to the monitoring system's address, and never to the whole internet:
- UFW:
ufw allow from 203.0.113.20 to any port 161 proto udp - firewalld:
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.20" port port="161" protocol="udp" accept'
On top of the firewall restriction, limit in the agent's own settings which addresses it accepts queries from.
Risks and security
In SNMPv1 and SNMPv2c, access is protected only by a Community String, a kind of shared password that crosses the network unencrypted. Many devices ship with the value public by default, so an agent open to the internet can expose information about the system and can also be abused for amplification attacks.
- Prefer SNMPv3 with authentication and encryption (authPriv).
- When you need version 2c, replace the default Community String with a long, random value, and allow read-only access.
- Limit access to the monitoring system's address, in the agent settings and in the firewall.
- Turn off the agent on devices that aren't monitored.
Commands to check and configure
-
ss -ulnp | grep ':161 'Checks whether an SNMP agent is listening on port 161, and on which address.
-
systemctl status snmpdShows whether the agent service is running.
-
snmpwalk -v3 -l authPriv -u monitor -a SHA -A AuthPassword -x AES -X PrivPassword 10.0.0.5 1.3.6.1.2.1.1Reads the device's basic system data over an encrypted connection (SNMPv3). Replace the username and passwords with the details set in the agent.
-
snmpget -v2c -c MyCommunity 127.0.0.1 1.3.6.1.2.1.1.3.0Checks from the server itself that the agent responds, and shows how long it has been running (version 2c, with the Community String you set).
-
ufw allow from 203.0.113.20 to any port 161 proto udpAllows only the given monitoring system to send queries to the agent (UFW).
-
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.20" port port="161" protocol="udp" accept'Allows only the given monitoring system to send queries to the agent in firewalld. Then run firewall-cmd --reload.
Port 161 in the IANA registry
| Port | Protocol | Service | IANA registry description |
|---|---|---|---|
| 161 | TCP | snmp | SNMP |
| 161 | UDP | snmp | SNMP |
Data source: IANA Service Name and Transport Protocol Port Number Registry (opens in a new tab)
Port 161 FAQ
What's the difference between SNMPv2c and SNMPv3?
In version 2c, access is protected only by a Community String, and everything travels unencrypted. With SNMPv3, you can give each monitoring system its own user, with password authentication and the option to encrypt the data. When your equipment supports it, we recommend using SNMPv3.
What's the difference between port 161 and port 162?
On port 161, the agent on the device receives queries from the monitoring system. On port 162, the monitoring system receives alerts that devices send on their own, for example when a network interface goes down.
What is a Community String in SNMP?
It's a kind of shared password that the monitoring system sends with every query in versions 1 and 2c. It travels unencrypted, so use a long, random value, allow read-only access, and restrict it to the monitoring system's address.
Can I monitor a Linux server over SNMP?
Yes. Install the agent (the net-snmp package, or the snmpd package on Debian and Ubuntu), set up an SNMPv3 user and an access restriction to the monitoring system's address, and open port 161 only to that address. The monitoring system can then read CPU load, memory, disks, and traffic.