0

I want to open some ports, both UDP and TCP, on a Fedora 32 server.

First, I've opened them on the router and then restarted the router:

router config

Then, I've opened them in firewalld:

sudo firewall-cmd --permanent --add-port=5000/tcp
sudo firewall-cmd --permanent --add-port=5000/udp
sudo firewall-cmd --permanent --add-port=2022/tcp
sudo firewall-cmd --permanent --add-port=2022/udp
sudo firewall-cmd --reload

But using nc on another computer, pinging the server, only one of them are open, namely TCP 2022:

$ nc -z -v -u $FTDB 5000                                                                                                                                                   (base) 324ms
Ncat: Version 7.80 ( https://nmap.org/ncat )
Ncat: Connected to XXXX
Ncat: Connection refused.
$ nc -z -v $FTDB 5000                                                                                                                                                      (base) 333ms
Ncat: Version 7.80 ( https://nmap.org/ncat )
Ncat: Connection refused.
$ nc -z -v $FTDB 2022                                                                                                                                                      (base) 347ms
Ncat: Version 7.80 ( https://nmap.org/ncat )
Ncat: Connected to XXXX
Ncat: 0 bytes sent, 0 bytes received in 0.34 seconds.
$ nc -z -v -u $FTDB 2022                                                                                                                                                        (base) 
Ncat: Version 7.80 ( https://nmap.org/ncat )
Ncat: Connected to XXXX
Ncat: Connection refused.

Other infomation:

firewall-cmd

sudo firewall-cmd --list-all                                                                                                                                     (base) 
FedoraWorkstation (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens5
  sources: 
  services: cockpit dhcpv6-client dns dns-over-tls docker-registry et https mdns mosh openvpn samba-client ssh
  ports: 1025-65535/udp 1025-65535/tcp 60000/udp 60001/udp 5000/udp 5000/tcp 2022/tcp 2022/udp 12345/udp 12345/tcp 12346/tcp 12346/udp 12347/tcp 12347/udp 9090/tcp 9090/udp
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 

ss:

ss -tulpn | grep '5000\|2022'                                                                                                                                    (base) 
tcp   LISTEN 0      32                             0.0.0.0:2022       0.0.0.0:*                                              
tcp   LISTEN 0      128                          127.0.0.1:5000       0.0.0.0:*    users:(("python",pid=3206,fd=65))         
tcp   LISTEN 0      32                                [::]:2022          [::]:*    

ifconfig:

ifconfig | grep -A 1 'ens5'                                                                                                                                      (base) 
ens5: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.101  netmask 255.255.255.0  broadcast 192.168.2.255

netstat:

netstat -lntu  | grep '5000\|2022'                                                                                                                               (base) 
tcp        0      0 0.0.0.0:2022            0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:5000          0.0.0.0:*               LISTEN     
tcp6       0      0 :::2022                 :::*                    LISTEN   
0

The issue was that a TCP service was running on the server on port 2022, but the service that was running on 5000 was only binding to 127.0.0.1. The particular service was a flask socketio app. I changed the code to socketio.run(app, host="0.0.0.0", port=5000).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.