3

I have a CentOS 7 server in which I opened up ports for SNMP connections.

Even though I can see the ports open here:

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

When I try to hit this port from the outside I always get that it's 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 (192.168.43.216)
Host is up (0.52s latency).
Not shown: 996 filtered ports
PORT      STATE  SERVICE
22/tcp    open   ssh
80/tcp    open   http
161/tcp   closed snmp
50000/tcp closed ibm-db2

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

Peter Mortensen
  • 2,318
  • 5
  • 23
  • 24
Matias Barrios
  • 213
  • 3
  • 12

1 Answers1

6

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
Michael Hampton
  • 244,070
  • 43
  • 506
  • 972