Using Centos Firewall how to assign multiple IPs to a Port?

mcv asked:

Setting up a new zone, with a port that has restricted access to an IP address. How does one apply this to more than one IP?

$ firewall-cmd --new-zone=special
$ firewall-cmd --permanent --zone=special --add-rich-rule='
  rule family="ipv4"
  source address=”"
  port protocol="tcp" port="10050" accept'

Is source address allowed an array of CSV? Is it defined like this?

source address=”″,”″

My answer:

You don’t need a rich rule for this. It’s unnecessary and too complicated for what you want to do.

Just add the source IP addresses and desired ports to the zone directly.

For example:

firewall-cmd --zone=special --add-source=
firewall-cmd --zone=special --add-source=
firewall-cmd --zone=special --add-source=

firewall-cmd --zone=special --add-port=10050/tcp

firewall-cmd --runtime-to-permanent

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.