How to filter packets based on source port without using direct rules
Environment
- Red Hat Enterprise Linux 8
- firewalld firewall
Issue
- Is there an option to filter packets via firewalld based on source port without having to use direct rules?
Resolution
The firewalld rich language can be used to allow source ports into a zone, eg:
firewall-cmd --add-rich-rule='rule source-port port="9001" protocol="udp" accept'
firewall-cmd --runtime-to-permanent
Root Cause
Rich rules are explained in detail on the manual at: man firewalld.richlanguage
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments