Common linux firewall configurations
RHLE7/centos7 firewall installed by default is firewall
Switch Service
Systemctl start firewalld. service
Systemctl stop firewalld. service
Emergency mode: Network disconnection
Firewall-cmd -- enable panic-on
Firewall-cmd -- disable panic-off
Firewall-cmd -- list-services view all services
Firewall-cmd
Parameter
-- List-all,-service
-- Status
-- Reload: reload the firewall configuration file
-- Get-zones: Obtain the list of supported regions
-- Get-service: get all supported services
-- Get-icmptype
Set the default Region
-- Set-defualt-zone = <zone>
Add an interface to a region
Firewall-cmd [-- zone = zone] -- add-interface = <interface>
Modify the interface
-- Change
Delete an interface from a region
-- Remove
Check whether an interface exists in the region.
-- Query
-- Get-zone-of -- interface = <interface>
Add or delete a service
-- Add-service
-- Remove-service
Example:
Add service to whitelist
Firewall-cmd -- add-service = dhcp (temporarily effective)
Firewall-cmd -- permanent -- add-service = ftp (add -- permanent will be written to the default zone/etc/firewalld/zones/public. xml, and -- reload is required to load the configuration)
Firewall-cmd -- reload
Add Port
Firewall-cmd -- permanent -- zone = public -- add-port = 80/tcp
Enable the ip camouflage function in the region
-- Add-masquerade
Port ing
Firewall-cmd -- permanent -- add-forward-port = 33: proto = tcp: toport = 22: toaddr = 172.16.7.8
{: Toport = <port> [-<port>]} |: toaddr = <address >|{: toport = <port> [-<port>]: totoaddr = <address>}