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

open all ports to specific IP with firewalld

· 52CE 我爱测

I'm on a red hat 7 machine, and I need to open all ports to a specific IP on the firewall. I tried this command: firewall-cmd --permanent --zone=public --add-rich-rule=' rule family="ipv4" source address="64.39.96.0/20" port prot…

问题原文

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

I'm on a red hat 7 machine, and I need to open all ports to a specific IP on the firewall.

I tried this command:

firewall-cmd --permanent --zone=public --add-rich-rule='   rule family="ipv4"   source address="64.39.96.0/20"   port protocol="tcp" port="*" accept'

But I'm getting an invalid port error for the *

Does anyone know and can tell me how to do this correctly?

已采纳解答

原帖链接 · Michael Hampton · CC BY-SA 3.0

Use a firewalld zone for this. Zones can be specified either by interface or by source IP address.

In fact, by default, a zone which accepts all traffic already exists, and it is named trusted. By default, though, nothing is in this zone. So, you don't even need to create a zone, just add the IP address to the trusted zone.

firewall-cmd --zone=trusted --add-source=64.39.96.0/20

In addition to CIDR ranges, you can specify single IP addresses or ipset names prefixed with ipset:.

After this, all traffic from the specified addresses will be allowed on any port. Remember to make it permanent, either by repeating the command with --permanent appended, or by running firewall-cmd --runtime-to-permanent.

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

资料来源与适用范围

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

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

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