Linux中有两种防火墙软件,ConterOS7.0以上使用的是firewall,ConterOS7.0如下使用的是iptables,本文将分别介绍两种防火墙软件的使用。shell
systemctl start firewalld
复制代码
systemctl stop firewalld
复制代码
systemctl status firewalld
复制代码
systemctl enable firewalld
复制代码
systemctl disable firewalld
复制代码
firewall-cmd --reload
复制代码
firewall-cmd --zone=public --add-port=8080/tcp --permanent
复制代码
firewall-cmd --list-ports
复制代码
firewall-cmd --zone=public --remove-port=8080/tcp --permanent
复制代码
因为CenterOS7.0以上版本并无预装Iptables,咱们须要自行装。tcp
yum install iptables
复制代码
yum install iptables-services
复制代码
systemctl start iptables.service
复制代码
systemctl stop iptables.service
复制代码
systemctl status iptables.service
复制代码
systemctl enable iptables.service
复制代码
systemctl disable iptables.service
复制代码
iptables -L -n
复制代码
iptables -t nat -L -n
复制代码
iptables -F
复制代码
iptables -X
复制代码
iptables -Z
复制代码
iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
复制代码
iptables -L INPUT --line-numbers -n
复制代码
iptables -D INPUT 1
复制代码
mall项目全套学习教程连载中,关注公众号第一时间获取。学习