firewall 与 iptables 基础使用

添加firewall或者iptables的端口   CentOS 6 使用service CentOS 7使用systemctl

--firewall CentOS 7自带

systemctl status firewalld

---添加端口或服务

firewall-cmd --permanent --add-service=http

firewall-cmd --reload

firewall-cmd --list-services

--常用命令

firewall-cmd --version

扫描二维码关注公众号,回复: 954286 查看本文章

查看所有打开的端口: 

firewall-cmd --zone=public --list-ports

--添加
firewall-cmd --zone=public --add-port=80/tcp --permanent   (--permanent永久生效,没有此参数重启后失效)
--重新载入
firewall-cmd --reload
--查看
firewall-cmd --zone=public --query-port=80/tcp
--删除
firewall-cmd --zone=public --remove-port=80/tcp --permanent

--iptables 安装

yum -y install iptables-services

--编辑配置文件1

vi /etc/sysconfig/iptables

--添加端口

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

--启动:

service iptables restart      #Centos6

systemctl restart iptables      #Centos7

--2

添加端口
/sbin/iptables -I INPUT -p tcp --dport 8000 -j ACCEPT
保存
/etc/rc.d/init.d/iptables save
重启服务
service iptables restart    或者  systemctl restart iptables

------------查看

service iptables status   或者  systemctl status iptables


猜你喜欢

转载自blog.csdn.net/ailice001/article/details/80309162