欢迎来到至成科技_西安服务器托管_西安服务器租用_西安域名注册
 售前免费咨询专线02989390727
时间:2014-10-03  来源:至成科技  作者:至成科技  点击次数:1655

防火墙起初看起来很难使用,但是实际上并不是这样。服务以及区域使一个个碎片的结合以及Linux防火墙的配置变得很容易。尽管工作在Linux内核的网络过滤器代码上,总体上和旧有的配置防火墙的方法是不兼容的。Red Hat Enterprise Linux 7 和其他的新版本则需要依靠新的配置方法。本文的所有命令都基于RHEL 7。

防火墙工作网络

首先,检查防火墙是否在运行。使用列表1中的systemctl status firewalld命令。

列表1.下面的序列表明防火墙是活动状态且在运行中。这些斜线是有帮助的,当你试图将表1显示出来,使用-1命令。

[root@rhelserver ~]# systemctl status firewalld

firewalld.service - firewalld - dynamic firewall daemon

   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled)

   Active: active (running) since Thu 2014-05-22 07:48:08 EDT; 14min ago

Main PID: 867 (firewalld)

   CGroup: /system.slice/firewalld.service

           └─867 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

May 22 07:48:08 rhelserver.example.com systemd[1]: Started firewalld - dynami...

防火墙中的一切都与一个或者多个区域相关联。

配置之后,RHEL 7服务器正常会在公共区域,但是你也许会想将它放置在另一个网络配置防火墙访问。这时使用firewall-cmd --get-default-zone命令,该命令显示你的服务器在哪一个网络。如果你想查看配置特定网络的详细信息,你可以使用列表2中的firewall-cmd --zone=zonename --list-all命令。

列表2.

root@rhelserver ~]# firewall-cmd --get-default-zone

public

  [root@rhelserver ~]# firewall-cmd --get-zones

  block dmz drop external home internal public trusted work

  [root@rhelserver ~]# firewall-cmd --zone=public --list-all

  public (default, active)

  interfaces: ens33

  sources:

  services: dhcpv6-client sander ssh

  ports:

  masquerade: no

  forward-ports:

  icmp-blocks:

  rich rules:

改变当前区域并不难:使用firewall-cmd --set-default-zone=home命令,该命令可用于从公共网络到家庭网络制定一个默认网络。

服务和其他构件

在区域中有一些基本的构件块,其中服务是较重要的。防火墙使用管理员创建在/usr/lib/firewalld/services(系统默认服务) 和/etc/firewalld/services文件下的XML文件,配置的自身服务集。XML文件时通过列表3中的例子创建的。

列表3.

[root@rhelserver services]# cat ftp.xml


  FTP

  FTP is a protocol used for remote file transfer. If you plan to make your FTP server publicly available, enable this option. You need the

vsftpd package installed for this option to be useful.

  

  


每一个服务定义都需要一个简短的名字、描述和端口网络用于指定需要使用的协议、端口和模块名。

列表4.以下是创建防火墙服务的例子

[root@rhelserver services]# cat sander.xml


  Sander

  Sander is a random service to show how service configuration works.

  


一旦你有了正确的服务文件,使用以下代码复制它。firewall-cmd --list-services命令显示从你服务器上的所有可以找到的服务列表。如果要增加服务则输入firewall-cmd --add-service yourservice将服务放到默认网络上,或者是使用--zone=zonename选择特定网络。

具体配置请看配置Linux防火墙的几种方式(下)篇,谢谢关注!

西安网站建设-至成科技光放微信

相关阅读:

陕西本土非营利性IDC互联网接入商/  Shanxi Local nonprofit IDC Internet access provider

公司地址:西安市经开区凤城四路西安国际企业中心B座23层06-10室

7*24小时售前咨询电话:02989390727

7*24小时售后服务电话:02989390727

《中华人民共和国增值电信业务经营许可证》陕B1.B2-20140011  陕ICP备12008874-2  © 2012-2024 ZCITIDC,Inc.

通信地址:西安市经开区凤城四路西安国际企业中心B座23层06-10室  邮政编码:710016

域名合作伙伴:新网互联软件服务有限公司

  • 西安服务器租用
  • 西安域名注册
  • 西安云主机
  • 西安VPS主机
  • 西安网站托管