大网数据广告活动
服务器运维问答

Block outgoing connections on RHEL7/CentOS7 with firewalld?

· 52CE 我爱测

RHEL7/CentOS7 features a new firewalld firewall service, that replaces the iptables service (both of which use iptables tool to interact with kernel's Netfilter underneath). firewalld can be easily tuned to block incoming traffic…

问题原文

原帖链接 · golem · CC BY-SA 3.0

RHEL7/CentOS7 features a new firewalld firewall service, that replaces the iptables service (both of which use iptables tool to interact with kernel's Netfilter underneath).

firewalld can be easily tuned to block incoming traffic, but as noted by Thomas Woerner 1,5 years ago "limiting outgoing traffic is not possible with firewalld in a simple way at the moment". And as far as I can see the situation hasn't changed since then. Or has it? Is there any way to block outgoing traffic with firewalld? If not are there any other "standard" ways (on RHEL7 distro) of blocking outgoing traffic except manually adding rules through iptables tool?

已采纳解答

原帖链接 · Fedora-user · CC BY-SA 3.0

I didn't find any option in that nice GUI, but it is possible via direct interface

To enable only outgoing port 80:

firewall-cmd --permanent --direct --add-rule ipv4 filter OUTPUT 0 -p tcp -m tcp --dport=80 -j ACCEPT
firewall-cmd --permanent --direct --add-rule ipv4 filter OUTPUT 1 -j DROP

This will add it to permanent rules, not the runtime rules.
You will need to reload permanent rules so they become runtime rules.

firewall-cmd --reload

to display permanent rules

firewall-cmd --permanent --direct --get-all-rules

to display runtime rules

firewall-cmd --direct --get-all-rules

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2014-08-05)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。