Centos 7 snmp port always closed

Matias Barrios asked:

So, I have a Centos 7 server in which I opened up ports for snmp connections.
The thing is even though I can see the ports open here :

[[email protected]_7_VM ~]$  sudo firewall-cmd --list-all
[sudo] password for matias: 
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33
  services: ssh dhcpv6-client
  ports: 80/tcp 10050/tcp 50000/tcp 161/tcp 160/tcp
  masquerade: no
  rich rules: 

When I try to hit this port from outside I always get that its closed. Even nmap agrees on this :

Starting Nmap 7.01 ( https://nmap.org ) at 2018-08-01 14:52 -03
Nmap scan report for Centos_7_VM (
Host is up (0.52s latency).
Not shown: 996 filtered ports
22/tcp    open   ssh
80/tcp    open   http
161/tcp   closed snmp
50000/tcp closed ibm-db2

What else can I do to open this ports?
( yes, I reloaded firewalld when I initially opened the ports )

My answer:

SNMP is a UDP protocol, not a TCP protocol. So you need to open the UDP port, i.e. 161/udp.

Better yet, just specify the service name and firewalld will take care of it.

firewall-cmd <options> --add-service=snmp

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.