How to open port for a specific IP address with firewall-cmd on CentOS? [duplicate]
Try this command
firewall-cmd --permanent --zone=public --add-rich-rule='
rule family="ipv4"
source address="1.2.3.4/32"
port protocol="tcp" port="4567" accept'
Check the zone file later to inspect the XML configuration
cat /etc/firewalld/zones/public.xml
Reload the firewall
firewall-cmd --reload
Create a new zone to accommodate this configuration. FirewallD zones are defined by source addresses and by interfaces.
firewall-cmd --new-zone=special --permanent
firewall-cmd --reload
firewall-cmd --zone=special --add-source=192.0.2.4/32
firewall-cmd --zone=special --add-port=4567/tcp
Add --permanent
of course to the latter two commands to make them permanent.