028-86922220

建站动态

根据您的个性需求进行定制 先人一步 抢占小程序红利时代

详述Linux中Firewalld高级配置-创新互联

IP伪装与端口转发

Firewalld支持两种类型的网络地址转换

地址伪装配置

firewall-cmd [--permanent] [--zone= zone] --add-masquerade [--timeout seconds]
 //--timeout=seconds:在一段时间后自动删除该功能
firewall-cmd [--permanent] [--zone= zone] --remove-masquerade
firewall-cmd [--permanent] [--zone=zone] --query-masquerade

端口转发配置

firewall-cmd [--permanent] [--zone=zone] --list-forward-ports
firewall-cmd [--permanent] [--zone=zone] --add-forward-port=port=portid[-portid]:proto=protocol[:toport-portid[-portid]][:toaddr-address[/mask]][--timeout=seconds]
firewall-cmd [--permanent] [--zone=zone] --remove-forward-port=port=portid[-portid]:proto=protocol[:toport=portid[-portid]][:toaddr=address[/mask]]
firewall-cmd [--permanent] [--zone=zone] --query-forward-port-port-portid[-portid]:proto=protocol[:toport-portid[-portid]][:toaddr=address[/mask]]

Firewalld直接规则

直接规则(direct interface)

自定义规则链

允许TCP/9000端口的入站流量

irewall-cmd --direct --add-rule ipv4 filter IN work_ allow 0 -p tcp --dport 9000 j ACCEPT

查询所有的直接规则

firewall-cmd --direct --get-all-rules
ipv4 filter IN_ work _allow 0 -p tcp --dport 9000 -j ACCEPT

Firewalld富语言规则

富语言(rich language)

rule [family=""]
  [ source address="
" [invert "True"] ] [ destination address="
" [invert="True"] ] [ ] [ log [prefix=""] [level=""] [limit value="rate/duration"] ] [ audit ] [ acceptlrejectldrop ]

理解富语言规则命令

选项 说明
-add-rich-rule= 'RULE'向指定区域中添加RULE,如果没有指定区域,则为默认区域
--remove-rich-rule= 'RULE'从指定区域中删除RULE,如果没有指定区域,则为默认区域
--query-rich-rule= 'RULE'查询RULE是否已添加到指定区域,如果未指定区域,则为默认区域。
规则存在,则返回0,否则返回1
--list-rich-rules输出指定区域的所有富规则,如果未指定区域,则为默认区域

已配置富语言规则显示方式

富语言规则具体语法

拒绝从192.168.8.101的所有流量

firewall-cmd --permanent --zone=work --add-rich-rule='rule family=ipv4 source address=192.168.8.101/32 reject'

接受192.168.1.0/24子网端口范置8000-9000的TCP流量

firewall-cmd --permanent --one=work --add-rich-rule='rule family=ipv4 source address=192.168.1.0/24 port port=8000-9000 protocol=tcp accept'

丢弃所有icmp包

firewall-cmd --permanent --add-rich-rule='rule protocol value=icmp drop'

接受来自192.168.8.1的http流量,并记录日志

firewall-cmd --add-rich-rule='rule family=ipv4 source address=192.168.8.1/32 service name="http" log level=notice prefix= "NEW HTTP”limit value "3/s" accept'
Apr 16 17:09:55 Server kernel: NEW HTTP IN=ens33 OUT=
MAC=00:0c:29:69:01:c4:00:50:56:c0:00:08:08:00 SRC=192.168.8.1 DST=192.168.8.131
LEN=52 TOS=0xOO PREC=0x00 TTL =64 ID=20582 DF PROTO=TCP SPT=65289 DPT=80
WINDOW=8192 RES=0x00 SYN URGP=0
Apr 16 17:09:55 Server kernel: NEW HTTP IN=ens33 OUT=
MAC=00:0c:29:69:01:c4:00:50:56:c0:00:08:08:00 SRC=192.168.8.1 DST=192.168.8.131
LEN=52 TOS=0x0O PREC=0x0O TTL =64 ID=20590 DF PROTO=TCP SPT=65291 DPT=80
WINDOW=8192 RES=0x00 SYN URGP=0
Apr 16 17:09:55 Server kernel: NEW HTTP IN=ens33 OUT=
MAC=00:0c:29:69:01:c4:00:50:56:c0:00:08:08:00 SRC=192.168.8.1 DST=192.168.8.131
LEN=52 TOS=0x0O PREC=0x0O TTL =64 ID=20602 DF PROTO=TCP SPT=65292 DPT=80
WINDOW=8192 RES=0x00 SYN URGP=0

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网页题目:详述Linux中Firewalld高级配置-创新互联
链接URL:http://www.tsicrk.com/article/dohhgh.html

其他资讯

让你的专属顾问为你服务

2.3812s