I. Saving and backing up iptables rules
Service Iptables Save//rules will be saved to/etc/sysconfig/iptables iptables-save > My.ipt//iptables rules back to My.ipt file iptabl Es-restore < My.ipt//restore Backup rules
Second, FIREWALLD
Open Firewalld
Systemctl Disable Iptablessystemctl Stop iptablessystemctl enable Firewalldsystemctl start Firewalldfirewalld default 9 zone default zone is Publicfirewall-cmd--get-zones//View all zones Note: There is no space in the middle of the firewall-cmd,-- Get-zones no space in the middle Firewall-cmd--get-default-zone//view default Zone
Firewall-cmd--set-default-zone=work//Set Default zone Firewall-cmd--GET-ZONE-OF-INTERFACE=ENS33//check specified net Card firewall-cmd--zone=public--add-interface=ens37//Set zone Firewall-cmd--ZONE=DMZ--CHANGE-INTERFACE=ENS37 for the specified NIC /change Zone Firewall-cmd--ZONE=DMZ--REMOVE-INTERFACE=ENS37//For network card remove zone Firewall-cmd--get-active-zones View the zone where all network cards are located
Third, servies
Firewall-cmd--get-services//View all servies firewall-cmd--list-services See what service is in the current zone
Firewall-cmd--zone=public--add-service=http//Add HTTP to the public zone Firewall-cmd--zone=public--remove-service=h TTP//Remove HTTP from below public zone
ls/usr/lib/firewalld/zones///zone configuration file Template/usr/lib/firewalld/services/ Services template Firewall-cmd--zone=public--add-service=http--permanent//Change profile, then generate configuration file under/etc/firewalld/zones directory
Requirements: FTP Service custom port 1121, need to release FTP under work zone
Cp/usr/lib/firewalld/services/ftp.xml/etc/firewalld/services vi/etc/firewalld/services/ftp.xml//change 21 to 1121 CP/USR /lib/firewalld/zones/work.xml/etc/firewalld/zones/vi/etc/firewalld/zones/work.xml//Add a line <service name= "ftp"/ > Firewall-cmd--reload//reload Firewall-cmd--zone=work--list-services
Linux Learning Notes (33) iptables Backup, Firewalld