linux防火墙firewall使用简介
1、firewalld的基本使用
启动: systemctl start firewalld
查看状态: systemctl status firewalld
停止: systemctl disable firewalld
禁用: systemctl stop firewalld
2.systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。
启动一个服务:systemctl start firewalld.service
关闭一个服务:systemctl stop firewalld.service
重启一个服务:systemctl restart firewalld.service
显示一个服务的状态:systemctl status firewalld.service
在开机时启用一个服务:systemctl enable firewalld.service
在开机时禁用一个服务:systemctl disable firewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service
查看已启动的服务列表:systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl --failed
3.配置firewalld-cmd
查看版本: firewall-cmd --version
查看帮助: firewall-cmd --help
显示状态: firewall-cmd --state
查看所有打开的端口: firewall-cmd --zone=public --list-ports
更新防火墙规则: firewall-cmd --reload
查看区域信息: firewall-cmd --get-active-zones
查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0
拒绝所有包:firewall-cmd --panic-on
取消拒绝状态: firewall-cmd --panic-off
查看是否拒绝: firewall-cmd --query-panic
那怎么开启一个端口呢
添加
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
暫時開放 ftp 服務
# firewall-cmd --add-service=ftp
永久開放 ftp 服務
# firewall-cmd --add-service=ftp --permanent
永久關閉
# firewall-cmd --remove-service=ftp --permanent
success
讓設定生效
# systemctl restart firewalld
檢視設定是否生效
# iptables -L -n | grep 21
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:21 ctstate NEW
檢查防火牆狀態
# firewall-cmd --state
running
# systemctl stop firewalld
# firewall-cmd --state
not running
# firewall-cmd --list-all
public (default)
interfaces:
sources:
services: dhcpv6-client ftp ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
在 FirewallD 的服務名稱
# firewall-cmd --get-service
amanda-client bacula bacula-client dhcp dhcpv6 dhcpv6-client dns ftp high-availability http https imaps ipp ipp-client ipsec kerberos kpasswd ldap ldaps libvirt libvirt-tls mdns mountd ms-wbt mysql nfs ntp openvpn pmcd pmproxy pmwebapi pmwebapis pop3s postgresql proxy-dhcp radius rpc-bind samba samba-client smtp ssh telnet tftp tftp-client transmission-client vnc-server wbem-https
查詢服務的啟用狀態
# firewall-cmd --query-service ftp
yes
# firewall-cmd --query-service ssh
yes
# firewall-cmd --query-service samba
no
# firewall-cmd --query-service http
no
自行加入要開放的 Port
# firewall-cmd --add-port=3128/tcp
# firewall-cmd --list-all
public (default)
interfaces:
sources:
services: dhcpv6-client ftp ssh
ports: 3128/tcp
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
启动FirewallD服务:
systemctl enable firewalld.service #设置开机启动systemctl start firewalld.service #开启服务 查看防火墙状态:
systemctl status firewalld
1. 区域管理
1.1. 网络区域简介
通过将网络划分成不同的区域,制定出不同区域之间的访问控制策略来控制不同程序区域间传送的数据流。例如,互联网是不可信任的区域,而内部网络是高度信任的区域。网络安全模型可以在安装,初次启动和首次建立网络连接时选择初始化。该模型描述了主机所连接的整个网络环境的可信级别,并定义了新连接的处理方式。有如下几种不同的初始化区域:
阻塞区域(block):任何传入的网络数据包都将被阻止。
工作区域(work):相信网络上的其他计算机,不会损害你的计算机。
家庭区域(home):相信网络上的其他计算机,不会损害你的计算机。
公共区域(public):不相信网络上的任何计算机,只有选择接受传入的网络连接。
隔离区域(DMZ):隔离区域也称为非军事区域,内外网络之间增加的一层网络,起到缓冲作用。对于隔离区域,只有选择接受传入的网络连接。
信任区域(trusted):所有的网络连接都可以接受。
丢弃区域(drop):任何传入的网络连接都被拒绝。
内部区域(internal):信任网络上的其他计算机,不会损害你的计算机。只有选择接受传入的网络连接。
外部区域(external):不相信网络上的其他计算机,不会损害你的计算机。只有选择接受传入的网络连接。
注:FirewallD的默认区域是public。
1.2. 显示支持的区域列表
firewall-cmd --get-zones
1.3. 设置为家庭区域
firewall-cmd --set-default-zone=home
1.4. 查看当前区域
firewall-cmd --get-active-zones
1.5. 设置当前区域的接口
firewall-cmd --get-zone-of-interface=enp03s
1.6. 显示所有公共区域(public)
firewall-cmd --zone=public --list-all
1.7. 临时修改网络接口(enp0s3)为内部区域(internal)
firewall-cmd --zone=internal --change-interface=enp03s
1.8. 永久修改网络接口enp03s为内部区域(internal)
firewall-cmd --permanent --zone=internal --change-interface=enp03s
2. 服务管理
2.1. 显示服务列表
Amanda, FTP, Samba和TFTP等最重要的服务已经被FirewallD提供相应的服务,可以使用如下命令查看:
firewall-cmd --get-services
2.2. 允许SSH服务通过
firewall-cmd --add-service=ssh
2.3. 禁止SSH服务通过
firewall-cmd --remove-service=ssh
2.4. 打开TCP的8080端口
firewall-cmd --add-port=8080/tcp
2.5. 临时允许Samba服务通过600秒
firewall-cmd --add-service=samba --timeout=600
2.6. 显示当前服务
firewall-cmd --list-services
2.7. 添加HTTP服务到内部区域(internal)
firewall-cmd --permanent --zone=internal --add-service=httpfirewall-cmd --reload #在不改变状态的条件下重新加载防火墙 3. 端口管理
3.1. 打开端口
#打开443/TCP端口firewall-cmd --add-port=443/tcp
#永久打开3690/TCP端口firewall-cmd --permanent --add-port=3690/tcp#永久打开端口好像需要reload一下,临时打开好像不用,如果用了reload临时打开的端口就失效了#其它服务也可能是这样的firewall-cmd --reload#查看防火墙,添加的端口也可以看到firewall-cmd --list-all
4. 直接模式
FirewallD包括一种直接模式,使用它可以完成一些工作,例如打开TCP协议的9999端口
firewall-cmd --direct -add-rule ipv4 filter INPUT 0 -p tcp --dport 9000 -j ACCEPTfirewall-cmd --reload5. 加入NAT转发功能
firewall-cmd --permanent --zone=public --add-rich-rule='rule family=ipv4 source address=10.8.0.0/24 masquerade'
6. 关闭服务的方法
你也可以关闭目前还不熟悉的FirewallD防火墙,而使用iptables,命令如下:
systemctl stop firewalldsystemctl disable firewalldyum install iptables-servicessystemctl start iptablessystemctl enable iptableslinux防火墙firewall使用简介的更多相关文章
- LINUX防火墙firewall、iptables
(1) 重启后永久性生效: 开启: systemctl enable iptables.service'.ln -s '/usr/lib/systemd/system/iptables.service ...
- Linux防火墙firewall和iptables的使用
防火墙是整个数据包进入主机前的第一道关卡. Linux中有两种防火墙软件,ConterOS 7.0以上使用的是 firewall,ConterOS 7.0以下使用的是 iptables,本文将分别介绍 ...
- linux 防火墙 firewall 设置
背景: 机房断电后导致机器关机重启,原先访问的地址访问不了,使用终端能访问到该服务器,服务启起来后,用curl + 地址能访问,但在外部浏览器访问不了该地址: 首先想到了端口限制----防火墙 参考博 ...
- Linux防火墙简介 – iptables配置策略
Linux防火墙简介 – iptables配置策略 Netfilter/iptables简介 要想真正掌握Linux防火墙体系,首先要搞清楚Netfilter和iptables的关系,Netfilte ...
- 【Redhat系列linux防火墙工具】firewalld与iptables防火墙工具的激烈碰撞
前言 iptables与firewalld防火墙管理工具在linux发行版Redhat7系列使用较为广泛. UFW则是在linux发行版Ubuntu下进行管理防火墙的一款管理工具. 在选用防火墙工具的 ...
- linux 防火墙 iptables 目录
linux iptables 防火墙简介 Linux 防火墙:Netfilter iptables 自动化部署iptables防火墙脚本
- Linux防火墙配置与管理(16)
防火墙指的是一个由软件和硬件设备组合而成.在内部网和外部网之间.专用网与公共网之间的边界上构造的保护屏障.是一种获取安全性方法的形象说法,它是一种计算机硬件和软件的结合,使Internet与Intra ...
- Linux防火墙工具Firestarter
Firestarter是一个非常好用的防火墙图形化配置工具,作者和开发者是芬兰人. 首先肯定的说Firestarter防火墙是一款非常优秀的基于GUI图形用户界面下的,完全免费的自由软件,它为中小型L ...
- linux初学者-firewall篇
linux初学者-firewall篇 firewalld是防火墙的另一种程序,与iptables相同,但是使用起来要比iptables简单的点,不需要了解3张表和5条链也可以使用. 1.firewa ...
随机推荐
- PHP开发环境及搭建
自学PHP中,很多东西都不熟悉,在此做个记录,方便以后再次搭建PHP环境.这篇文章基本按照原文 ThinkPHP5开发环境安装和配置 ,在此感谢该作者 一.实验目的 1.掌握ThinkPHP5(简称 ...
- [转]c# 泛类型(泛型) 以及强类型与弱类型的 理解及优化
[泛型的概念](1)没有泛型的时候,所有的对象都是以object为基础,如果要使用时必须进行强制类型转换,如果对于值类型,则会导致不断拆箱装箱的过程,对系统消耗很大.(2)使用泛型时不需要通过obje ...
- 有关在python中使用Redis(二)
这里简单介绍下在python中使用如何使用hashset,set和list: 从list开始: 一般我们使用lpush对一个list进行初始化添加,但是如果需要不断往这个list里面加值,就要用rpu ...
- spring data jpa 简单使用
通过解析方法名创建查询 通过前面的例子,读者基本上对解析方法名创建查询的方式有了一个大致的了解,这也是 Spring Data JPA 吸引开发者的一个很重要的因素.该功能其实并非 Spring Da ...
- linux-2.6.22.6/Makefile:416: *** mixed implicit and normal rules: deprecated syntax
今天在按照韦东山大哥的教程流程编译内核的时候出现了这个问题 linux-2.6.22.6/Makefile:416: *** mixed implicit and normal rules: ...
- linux命令行—《命令行快速入门》
pwd print working directory 打印工作目录 hostname my computer's network name 电脑在网络中的名称 mkdir make director ...
- UIButton 图片文字位置
在实际开发过程中经常在按钮上添加文字和图片,位置和图片的位置根据需求放置也是不一样的.下面实现了各种显示方式,如下图: UIButton+LSAdditions.h // // UIButton+LS ...
- 安装python3后,没有Scripts目录的解决办法
设置好python环境变量后,执行命令即可:python -m ensurepip
- javase基础-Helloword
public class HelloWorld {//创建一个类 :1.类名首字母需要大写:2.类名必须和文件名一致 public static void main(String[] ...
- HYSBZ 1010 玩具装箱toy (决策单调DP)
题意: 有n个玩具,要将它们分为若干组,玩具长度C可能不同.给出n个玩具的摆放顺序,连续的任意多个玩具都可以成为一组.区间[i,j]成为一组的费用是cost=(j-i+Sigma(Ck)-L)2且i& ...