我计划配置一个策略路由,对来自10.0.101.9的流量直接通过interface GigabitEthernet1/0/1出去,下面是我的相关配置,但没有生效;我使用disp ip policy-based-route interface g1/0/1看不到单个的匹配包;请问我这个是什么原因不生效;使用哪个命令查看匹配的每一个包的详细细节消息
interface GigabitEthernet1/0/1
port link-mode route
description GigabitEthernet1/0/1 Interface ӿ
ip address 3.3.3.206 255.255.255.0
tcp mss 1300
ip last-hop hold
nat outbound
nat hairpin enable
ip policy-based-route SREtoCNM
ipsec apply policy swan
ip route-static 0.0.0.0 0 GigabitEthernet1/0/1 3.3.3.1
ip route-static 0.0.0.0 0 GigabitEthernet1/0/2 10.0.1.1 tag 2
ip route-static 10.0.3.0 24 10.0.254.5
ip route-static 10.0.100.0 24 10.0.254.1
ip route-static 10.0.0.0 24 10.0.250.1 preference 50
ip route-static 10.0.180.0 24 10.0.254.1
ip route-static 10.0.200.0 24 10.0.254.1
policy-based-route SREtoCNM permit node 5
if-match acl 3001
apply output-interface GigabitEthernet1/0/1
acl advanced 3001
rule 0 permit ip source 10.0.101.9 0
=========debug==========
[H3C]disp ip policy-based-route setup
Policy Name Interface Name
SREtoCNM GigabitEthernet1/0/1
[H3C]disp ip policy-based-route interface g1/0/1
Policy based routing information for interface GigabitEthernet1/0/1:
Policy name: SREtoCNM
node 5 permit:
if-match acl 3001
apply output-interface GigabitEthernet1/0/1
Matched: 0
Total matched: 0
[H3C]disp ip policy-based-route
Policy name: SREtoCNM
node 5 permit:
if-match acl 3001
apply output-interface GigabitEthernet1/0/1
<H3C>disp version H3C Comware Software, Version 7.1.064, Release 9524P35 Copyright (c) 2004-2020 New H3C Technologies Co., Ltd. All rights reserved. H3C SecPath F1000-905-AI uptime is 2 weeks, 6 days, 14 hours, 38 minutes Last reboot reason: User reboot Boot image: flash:/f1010fw-cmw710-boot-R9524P35.bin Boot image version: 7.1.064, Release 9524P35 Compiled Oct 09 2020 16:00:00 System image: flash:/f1010fw-cmw710-system-R9524P35.bin System image version: 7.1.064, Release 9524P35 Compiled Oct 09 2020 16:00:00 SLOT 1 CPU type: Multi-core CPU DDR3 SDRAM Memory 2032M bytes Board PCB Version:Ver.A Basic BootWare Version: 2.00 Extend BootWare Version: 2.00 [SubSlot 0]8GE (Hardware)Ver.A, (Driver)1.0 Boot Type: Cold,没有display ip policy-based-route statistics verbose,是版本太低了吗
<H3C>disp version H3C Comware Software, Version 7.1.064, Release 9524P35 Copyright (c) 2004-2020 New H3C Technologies Co., Ltd. All rights reserved. H3C SecPath F1000-905-AI uptime is 2 weeks, 6 days, 14 hours, 38 minutes Last reboot reason: User reboot Boot image: flash:/f1010fw-cmw710-boot-R9524P35.bin Boot image version: 7.1.064, Release 9524P35 Compiled Oct 09 2020 16:00:00 System image: flash:/f1010fw-cmw710-system-R9524P35.bin System image version: 7.1.064, Release 9524P35 Compiled Oct 09 2020 16:00:00 SLOT 1 CPU type: Multi-core CPU DDR3 SDRAM Memory 2032M bytes Board PCB Version:Ver.A Basic BootWare Version: 2.00 Extend BootWare Version: 2.00 [SubSlot 0]8GE (Hardware)Ver.A, (Driver)1.0 Boot Type: Cold,没有display ip policy-based-route statistics verbose,是版本太低了吗
ip policy-based-route,属于无效配置。10.0.101.9 流量的真实物理入口。如果该流量是从其他网段经由内网接口进入防火墙,那么 ip policy-based-route SREtoCNM 必须应用在对应的内网入接口下,而不是您期望的出接口 GigabitEthernet1/0/1 上。10.0.101.9 0。在 H3C 设备中,0 代表完全匹配,即仅能匹配 10.0.101.9 这一个 IP。如果实际测试时使用的是该网段的其他 IP(例如 10.0.101.10),则会导致 ACL 无法命中,从而匹配计数为 0。/24 网段,应将掩码修改为 10.0.101.0 0.0.0.255。apply output-interface GigabitEthernet1/0/1,但 PBR 的执行逻辑是“先匹配 ACL,再执行动作,最后校验下一跳”。如果指定的出接口物理状态非 UP,或者没有关联有效的直连路由/静态路由,PBR 会静默失效并回退到普通路由表查表。ping -a 10.0.101.9 3.3.3.1 (假设 3.3.3.1 为该出口的网关)来验证下一跳是否绝对可达。portswitch 命令(作为二层透传接口),报文到达后会直接进行二层 MAC 转发,而不会上送三层模块处理,因此永远不会匹配三层 PBR 策略。GigabitEthernet1/0/1 处于三层路由模式(undo portswitch)。从您的配置看已有 port link-mode route,此项可排除。display ip policy-based-route interface 统计计数为 0 时,可以通过开启 Debug 功能来抓取包级别的匹配细节:terminal monitor
terminal debuggingdebug ip packet acl 3001 verbose10.0.101.9 发起 ping 或 HTTP 请求。
直接告诉你:你的策略路由不生效,是因为绑定接口绑反了!
这是 H3C 防火墙 PBR 最经典、最常见的错误。
一、核心错误(100% 确定)
plaintext
interface GigabitEthernet1/0/1
ip policy-based-route SREtoCNM ❌ 错误!
为什么错?
策略路由必须绑定在【流量入方向接口】(内网口 / Trunk 口 / 用户侧接口)
你绑在了 出接口(外网口 1/0/1) → 流量根本不会匹配 PBR
所以 Matched: 0
二、正确配置(立刻生效)
1. 先删除错误绑定
plaintext
interface GigabitEthernet1/0/1
undo ip policy-based-route SREtoCNM
2. 找到内网口(10.0.101.9 所在的接口)
假设内网口是 GigabitEthernet1/0/3(你换成自己的)
plaintext
interface GigabitEthernet1/0/3
ip policy-based-route SREtoCNM
PBR 必须绑在流量进来的接口(内网口)
三、你的配置其他问题(一并修复)
1. ACL 3001 写法不标准(H3C 建议完整写法)
plaintext
acl advanced 3001
rule 0 permit ip source 10.0.101.9 0.0.0.0 ✅ 正确
你原来的 0 可以用,但建议写全 0.0.0.0 避免识别异常。
2. 策略路由推荐用下一跳,比出接口更稳定
plaintext
policy-based-route SREtoCNM permit node 5
if-match acl 3001
apply ip next-hop 3.3.3.1 ✅ 推荐
// apply output-interface GigabitEthernet1/0/1 ❌ 可以删掉
四、查看匹配的命令(你要的详细查看方法)
1. 查看 PBR 匹配包数(最常用)
plaintext
display ip policy-based-route interface 内网口
2. 查看 ACL 是否命中
plaintext
display acl 3001
如果这里有匹配,PBR 没匹配 → 接口绑定错误
3. Debug 查看详细转发(高级排错)
plaintext
terminal monitor
terminal debugging
debugging ip policy-based-route event
debugging ip policy-based-route packet
五、最终可直接用的正确配置
plaintext
# 1. 删掉错误绑定
interface GigabitEthernet1/0/1
undo ip policy-based-route SREtoCNM
# 2. 绑定到内网口(务必改成你自己的内网口)
interface GigabitEthernet1/0/3
ip policy-based-route SREtoCNM
# 3. 策略路由(推荐用下一跳)
policy-based-route SREtoCNM permit node 5
if-match acl 3001
apply ip next-hop 3.3.3.1
# 4. ACL
acl advanced 3001
rule 0 permit ip source 10.0.101.9 0.0.0.0
六、一句话总结
策略路由 PBR 必须绑定在内网入接口,不能绑在外网出接口。
你绑反了,所以永远匹配 0。
亲~登录后才可以操作哦!
确定你的邮箱还未认证,请认证邮箱或绑定手机后进行当前操作
举报
×
侵犯我的权益
×
侵犯了我企业的权益
×
抄袭了我的内容
×
原文链接或出处
诽谤我
×
对根叔社区有害的内容
×
不规范转载
×
举报说明