我只想允许我的 centos 7.3 服务器上的某些 ip 范围使用 firewalld 访问。所以在这里我的防火墙规则
firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens160
sources:
services: dhcpv6-client ssh
ports:
protocols:
masquerade: no
forward-ports:
sourceports:
icmp-blocks:
rich rules:
rule family="ipv4" source address="x.x.x.x/22" port port="80" protocol="tcp" accept
rule family="ipv4" source address="192.168.209.0/24" port port="80" protocol="tcp" accept
rule family="ipv4" source address="1.2.3.4/32" port port="80" protocol="tcp" reject
rule family="ipv4" source address="0.0.0.0/0" port port="80" protocol="tcp" reject
但是我仍然可以从端口 80 上的 x.x.x.x 访问,我不明白为什么
使用IP表,这里是使用我的防火墙conf
创建的Chain IN_public_allow (1 references)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh ctstate NEW
ACCEPT tcp -- x.x.x.x/22 anywhere tcp dpt:http ctstate NEW
ACCEPT tcp -- X.X.X.X/16 anywhere tcp dpt:http ctstate NEW
ACCEPT tcp -- ipgg.sdv.fr anywhere tcp dpt:http ctstate NEW
ACCEPT tcp -- x.x.x.x/24 anywhere tcp dpt:http ctstate NEW
ACCEPT tcp -- x.x.x.x/24 anywhere tcp dpt:http ctstate NEW
Chain IN_public_deny (1 references)
target prot opt source destination
REJECT tcp -- ns3098611.ip-94-23-44.eu anywhere tcp dpt:http ctstate NEW reject-with icmp-port-unreachable
REJECT tcp -- anywhere anywhere tcp dpt:http ctstate NEW reject-with icmp-port-unreachable
但似乎从未考虑过。相反,我认为这个规则首先适用
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
ACCEPT all -- anywhere anywhere
我从零开始,这是我的历史
1208 服务码头工人停止 1209 SUDO IPtables -P 输入接受 1210 sudo iptables -P 前向接受 1211 SUDO IPTABLES -P 输出接受 1214 个 -F 1215 个 iptables -X 1216 个 -L 1217 服务码头程序启动 1221防火墙-cmd --全部列表
我只看到通过链输入的trafic
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
513 38048 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
0 0 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
2698 382K INPUT_direct all -- * * 0.0.0.0/0 0.0.0.0/0
2698 382K INPUT_ZONES_SOURCE all -- * * 0.0.0.0/0 0.0.0.0/0
2698 382K INPUT_ZONES all -- * * 0.0.0.0/0 0.0.0.0/0
3 132 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate INVALID
2691 382K REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
您的默认策略是 ACCEPT,因此除非存在删除或拒绝规则,否则将接受所有内容。但是,更重要的是,您的第一条规则似乎专门允许从 x.x.x.x 到端口 80 的流量?
您也可以检查 ipv6,您的所有规则都适用于 ipv4,因此如果 ipv6 处于活动状态,则它可能处于打开状态。