SUSE Linux系统firewall防火墙配置

本文详细介绍了在SUSE12系统中如何操作和管理SuSEfirewall2防火墙服务,包括启动、关闭、重启,以及配置文件中的FW_SERVICES_EXT_TCP和FW_SERVICES_ACCEPT_EXT的区别。

suse12下操作为

关闭防火墙服务:

systemctl stop SuSEfirewall2.service

取消开机启动防火墙服务

systemctl disable SuSEfirewall2.service

开机开启防火墙服务

systemctl enable SuSEfirewall2.service

启动防火墙服务

systemctl start SuSEfirewall2.service

查询防火墙服务状态

systemctl status SuSEfirewall2.service

根据帮助命令查看

SUSE-12:~ # /sbin/SuSEfirewall2 -h

SuSEfirewall2 3.6, Copyright (C) 2005  SUSE LINUX Products GmbH

stateful packet filter rules generator for iptables.

/sbin/SuSEfirewall2 start|test|debug [file FILENAME]

/sbin/SuSEfirewall2 basic|stop|close|status|help

/sbin/SuSEfirewall2 open ZONE TYPE services...

/sbin/SuSEfirewall2 on|off

/sbin/SuSEfirewall2 [-s <service>] update-rpc

Options:

  start          generate and load the firewall filter rules from

              /etc/sysconfig/SuSEfirewall2

  stop        unload all filter rules

  close       no incoming network traffic except bootp+ping (for boot security)

  basic       set basic filter rules that drop all incoming access

  test        generate and load the filter rules but do not drop any packet but log

              to syslog anything which *would* be denied

  status      print the output of "iptables -nvL"

 

3. SuSEfirewall2配置文件中FW_SERVICES_EXT_TCP与FW_SERVICES_ACCEPT_EXT的区别:

FW_SERVICES_EXT_TCP 不能做更详细的配置,只有允许和不允许两种配置,不能过滤IP,只能过滤端口;

FW_SERVICES_ACCEPT_EXT 可以做更详细的配置和限制,对IP和端口同时作限制;

但是,如果对同一端口既然配置了FW_SERVICES_EXT_TCP,也配置了FW_SERVICES_ACCEPT_EXT,则系统优先使用

FW_SERVICES_EXT_TCP配置项。

4. 如果有一种场景,既要让指定的IP能访问22端口,又要让所有IP能访问80端口,则这样配置:

FW_SERVICES_EXT_TCP = “80”   #多个端口用空格分开

FW_SERVICES_EXT_TCP="ftp 22 telnet 512:514"  #开放ftp,ssh,telnet,512-514这些端口

FW_SERVICES_ACCEPT_EXT="192.168.1.100,tcp,22"

Format: space separated list of net,protocol[,dport[,sport[,flags]]]

# Example: "0/0,tcp,22"

#

# Supported flags are

#   hitcount=NUMBER     : ipt_recent --hitcount parameter

#   blockseconds=NUMBER : ipt_recent --seconds parameter

#   recentname=NAME     : ipt_recent --name parameter

# Example:

#    Allow max three ssh connects per minute from the same IP address:

#      "0/0,tcp,22,,hitcount=3,blockseconds=60,recentname=ssh"

每分钟来自相同ip最大3个ssh链接的语法

如果要对同一个source IP开放多个端口,应将相同的IP写两个,中间用空格隔开

FW_SERVICES_ACCEPT_EXT="192.168.1.100 192.168.1.100,tcp,22 8080 80"

如果对多个source ip 开放ssh端口,配置如下,不能开多行

FW_SERVICES_ACCEPT_EXT="10.1.1.1 20.1.1.1 30.1.1.1,tcp,22"

5. /etc/sysconfig/SuSEfirewall2配置文件中也有相应的详细说明。

firewall配置变更后,需要restart防火墙服务

systemctl restart SuSEfirewall2

配置变更完后,可以通过命令/sbin/SuSEfirewall2 status 查看防火墙端口状态。

SUSE Linux 11 中,防火墙配置文件是 `/etc/sysconfig/SuSEfirewall2`。你可以使用编辑器打开该文件并进行相应的配置。 以下是一个示例配置文件的内容: ``` ## Path: Security/Firewall ## Description: SuSEfirewall2 basic configuration ## Type: string(basic,noservices,masquerading,advanced,custom) ## Default: basic # # SuSEfirewall2 configuration # based on /etc/sysconfig/scripts/SuSEfirewall2-3.6.312-1.1 # last modified Tue Jul 6 12:58:32 UTC 2010 by root <root@localhost> # Modified by YaST2 at Thu Feb 22 14:45:34 CET 2018 FW_DEV_EXT="eth0" # External network interface FW_DEV_INT="eth1" # Internal network interface FW_FORWARD="yes" # Enable packet forwarding FW_MASQUERADE="yes" # Enable masquerading FW_SERVICES_EXT_TCP="22 80" # TCP services allowed from external network FW_SERVICES_EXT_UDP="" # UDP services allowed from external network FW_SERVICES_INT_TCP="" # TCP services allowed from internal network FW_SERVICES_INT_UDP="" # UDP services allowed from internal network FW_SERVICES_DMZ_TCP="" # TCP services allowed from DMZ network FW_SERVICES_DMZ_UDP="" # UDP services allowed from DMZ network # ... 其他配置 ... ``` 你可以根据需要修改上述配置文件中的参数。例如,你可以添加或删除允许通过防火墙的端口,指定内部和外部网络接口等。修改完成后,保存文件并重启防火墙服务以使配置生效。 注意:在进行任何配置更改之前,请确保你已备份原始配置文件以防止意外情况发生。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值