To enable inbound and outbound TCP traffic specifically for port 18917 using ufw on Debian 12, follow these steps:

  1. Allow inbound TCP traffic on port 18917:
sudo ufw allow 18917/tcp
  1. Allow outbound TCP traffic on port 18917 (if you have restricted outgoing traffic):
sudo ufw allow out to any port 18917 proto tcp
  1. Check the UFW status to confirm the rules have been applied:
sudo ufw status verbose

If you’re using firewalld instead of ufw, the equivalent commands are:

  1. Allow inbound TCP traffic on port 18917:
sudo firewall-cmd --zone=public --add-port=18917/tcp --permanent
  1. Allow outbound TCP traffic on port 18917:
sudo firewall-cmd --zone=public --add-forward-port=port=18917:proto=tcp:toport=18917 --permanent
  1. Reload firewalld to apply the changes:
sudo firewall-cmd --reload
  1. Verify the settings:
sudo firewall-cmd --list-all

This should allow TCP traffic on port 18917 in both directions.