Difference between revisions of "Red Hat / Centos firewall"

From MyWiki
Jump to: navigation, search
Line 22: Line 22:
 
  public
 
  public
 
   interfaces: eth0 eth1
 
   interfaces: eth0 eth1
 +
sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0<br>
 +
ZONE=

Revision as of 11:14, 19 July 2016

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

firewall-cmd --state
sudo systemctl start firewalld.service
firewall-cmd --get-default-zone
firewall-cmd --get-active-zones
firewall-cmd --list-all
firewall-cmd --get-zones
firewall-cmd --zone=home --list-all
sudo firewall-cmd --zone=home --change-interface=eth0
firewall-cmd --get-active-zones

If the firewall is completely restarted, the interface will revert to the default zone:
   sudo systemctl restart firewalld.service
   firewall-cmd --get-active-zones
output
public
 interfaces: eth0 eth1

sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0
ZONE=