Linux 防火墙的设置

时间:2020-03-26
本文章向大家介绍Linux 防火墙的设置,主要包括Linux 防火墙的设置使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

一、当前的操作系统为

[root@csxt ~]# more /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@csxt ~]#

二、当前版本的防火墙设置操作如下:

1、查看firewall的状态(关闭后显示notrunning,开启后显示running)

[root@csxt ~]# firewall-cmd --state  

2、开启firewalld.service服务

[root@csxt ~]# service firewalld start

3、重启firewalld.service服务

[root@csxt ~]# service firewalld restart

4、关闭firewalld.service服务

[root@csxt ~]# service firewalld stop

5、重新载入firewalld.service服务

[root@csxt ~]# firewall-cmd --reload

6、查看firewalld.service规则

[root@csxt ~]# firewall-cmd --list-all

7、开启TCP端口(如:开启80端口)

[root@csxt ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent

8、开启UDP端口(如:开启1000端口)

[root@csxt ~]# firewall-cmd --zone=public --add-port=1000/udp --permanent

9、开启规定范围多个端口

[root@csxt ~]# firewall-cmd --zone=public --add-port=80-90/tcp --permanent

10、删除指定端口规则(如:删除80端口)

[root@csxt ~]# firewall-cmd --zone=public --remove-port=80/tcp --permanent

11、对指定的IP开放指定的端口段

[root@csxt ~]# firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.1.100" port protocol="tcp" port="80" accept"

【命令含义】:
–zone #作用域
–add-port=80/tcp #添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效
————————————————————————————————————————————————
【原博主连接】https://blog.csdn.net/qq_35012243/article/details/82745126

原文地址:https://www.cnblogs.com/yuezc/p/12575107.html