SpringBoot实战电商项目商城(20k+star)地址:https://github.com/macrozheng/mall摘要Linux中有两款防火墙软件,ConterOS7.0和以上使用防火墙,ConterOS7.0以下使用iptables,本文将分别介绍两款防火墙软件的使用。防火墙开启防火墙:systemctlstartfirewalld关闭防火墙:systemctlstopfirewalld查看防火墙状态:systemctlstatusfirewalld设置开机启动:systemctlenablefirewalld禁用开机启动:systemctldisablefirewalld重启防火墙:firewall-cmd--reload开启端口(修改防火墙后重启即可生效):firewall-cmd--zone=public--add-port=8080/tcp--permanent查看开放端口:firewall-cmd--list-ports关闭端口:firewall-cmd--zone=public--remove-port=8080/tcp--permanentIptables安装由于CenterOS7.0以上版本没有预装Iptables,所以需要我们自己安装。安装前关闭防火墙安装iptables:yuminstalliptables安装iptables-services:yuminstalliptables-services使用打开防火墙:systemctlstartiptables.service关闭防火墙:systemctlstopiptables.service查看防火墙状态:systemctlstatusiptables.service设置开机启动:systemctlenableiptables.serviceDisablebootingStartup:systemctldisableiptables.service查看filter表的链式规则(INPUT链可以看到哪些端口是开放的):iptables-L-n查看NAT表的链式规则:iptables-tnat-L-n清除所有防火墙规则:iptables-Fiptables-Xiptables-Z在INPUT链中添加规则(开放8080端口):iptables-IINPUT-ptcp--dport8080-jACCEPT找到对应的行号rule:iptables-LINPUT--line-numbers-n根据行号删除过滤规则(关闭8080端口):iptables-DINPUT1公众号mall项目全套学习教程正在连载中,付费第一次关注公众号。
