Get the App
SLTechnology News&Howtos  ›  Servers  › 

Centos 7 disable selinux disable firewall

Shulou Source: shulou.com Published: 2022-06-03 03:22:29 10月27日 Update

1. Disable selinux

/sbin/setenforce 0sed -i 's\SELINUX=enforcing\SELINUX=disabled\' /etc/selinux/config

2. Disable firewall

systemctl stop firewalld.service systemctl disable firewalld.service

3. Enable firewall

systemctl start firewalld.servicesystemctl enable firewalld.service

4. Firewall command

#rename computer name hostnamectl set-hostname centos7_node200#view firewall status firewall-cmd --state #update firewall rules firewall-cmd --reload #View firewall status firewall-cmd --state #overload firewall rules firewall-cmd --reload #View all open ports firewall-cmd --list-ports #View all allowed services firewall-cmd --list-services #Get all supported services firewall-cmd --get-services #View all zones firewall-cmd --list-all-zones #View active zones firewall-cmd --get-active-zones #Set public to default zone firewall-cmd --set-default-zone=public #View default zone info firewall-cmd --get-default-zone #Add interface eth0 to zone publicfirewall-cmd --zone=public --add-interface=eth0 #Remove interface eth0 firewall-cmd --zone=public --remove-interface=eth0 from zone public #Modify the zone to which eth0 belongs to default firewall-cmd --zone=default --change-interface=eth0 #View the zone to which eth0 belongs firewall-cmd --get-zone-of-interface=eth0

5. Configure firewall rules

--permanent means permanent

#permanently add port 22 exception (zone public)firewall-cmd --permanent --zone=public --add-port=22/tcp #permanently remove port 22 exception (zone public)firewall-cmd --permanent --zone=public --remove-port=22/tcp #Block access to ssh services on segment 192.168.10.0/24 firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" source address="192.168.10.0/24" service name="ssh" reject" #firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" source address=" 192.168.0.4/24 " port protocol="tcp" port="8080" accept

Tags: Zone firewall fire protection interface port information rule permanent service ownership status face command address meaning network segment computer support update activity Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia OPPO Reno Huawei Shulou Information Docker