华为路由策略配置

一、AS_Path过滤

要求:

AR1 与AR2、AR2与AR3之间建立EBGP连接

AS10 的设备和AS30的设备无法相互通信

1. 启动设备

2. 配置IP地址

3. 配置路由器的EBGP对等体连接,引入直连路由

AR1\]bgp 10 \[AR1-bgp\]router-id 1.1.1.1 \[AR1-bgp\]peer 200.1.2.2 as-number 20 \[AR1-bgp\]import-route direct \[AR2\]bgp 20 \[AR2-bgp\]router-id 2.2.2.2 \[AR2-bgp\]peer 200.1.2.1 as-number 10 \[AR2-bgp\]peer 200.1.3.2 as-number 30 \[AR2-bgp\]import-route direct \[AR3\]bgp 30 \[AR3-bgp\]router-id 3.3.3.3 \[AR3-bgp\]peer 200.1.3.1 as-number 20 \[AR3-bgp\]import-route direct **验证:** **查看BGP路由表** **AR2** **:**display bgp routing-table ![](https://i-blog.csdnimg.cn/direct/a2119c05d2604568bd866ad77a965c50.png) **AR1** **:**display bgp routing-table ![](https://i-blog.csdnimg.cn/direct/0997c049b7b640b691f92ee1dd759ce4.png) **AR3** **:**display bgp routing-table ![](https://i-blog.csdnimg.cn/direct/257b9e94c61146669fd551f3407f83a2.png) **可以看到AR2发布自己引入的直连路由,向AR3发布了AS10引入的直连路由,向AR1发布了AS30引入的直连路由** **pc1** **和pc2可以通信** ![](https://i-blog.csdnimg.cn/direct/edc72d4c101e458f8f1aa3c830730970.png) **4.** **配置AS_Path过滤** \[AR2\]ip as-path-filter path-filter1 deny _30_ \[AR2\]ip as-path-filter path-filter1 permit .\* \[AR2\]ip as-path-filter path-filter2 deny _10_ \[AR2\]ip as-path-filter path-filter2 permit .\* **5.** **应用AS_Path过滤** \[AR2\]bgp 20 \[AR2-bgp\]peer 200.1.2.1 as-path-filter path-filter1 export \[AR2-bgp\]peer 200.1.3.2 as-path-filter path-filter2 export **验证:** **pc1** **和pc2不能通信** ![](https://i-blog.csdnimg.cn/direct/75c62ef5b23749ada8bcb76c7630318a.png) **二、OSPF接收和发布路由过滤** ![](https://i-blog.csdnimg.cn/direct/cbfa7029860e4fe18f24d0ec4440d996.png) **要求:** **OSPF** **网络只能访问172.1.17.0/24、172.1.18.0/24和172.1.19.0/24三个网段的网络,AR3连接的网络只能访问172.1.18.0/24网段的网络** **1.** **启动设备** **2.** **配置IP地址** **3.** **配置OSPF** \[AR1\]ospf \[AR1-ospf-1\]area 0 \[AR1-ospf-1-area-0.0.0.0\]network 192.168.1.0 0.0.0.255 \[AR2\]ospf \[AR2-ospf-1\]area 0 \[AR2-ospf-1-area-0.0.0.0\]network 192.168.1.0 0.0.0.255 \[AR2-ospf-1-area-0.0.0.0\]network 192.168.2.0 0.0.0.255 \[AR2-ospf-1-area-0.0.0.0\]network 192.168.3.0 0.0.0.255 \[AR3\]ospf \[AR3-ospf-1\]area 0 \[AR3-ospf-1-area-0.0.0.0\]network 192.168.2.0 0.0.0.255 \[AR4\]ospf \[AR4-ospf-1\]area 0 \[AR4-ospf-1-area-0.0.0.0\]network 192.168.3.0 0.0.0.255 **4.** **在AR1上配置5条静态路由,并引入OSPF协议(5条静态路由为黑洞静态路由)** \[AR1\]ip route-static 172.1.16.0 24 NULL 0 \[AR1\]ip route-static 172.1.17.0 24 NULL 0 \[AR1\]ip route-static 172.1.18.0 24 NULL 0 \[AR1\]ip route-static 172.1.19.0 24 NULL 0 \[AR1\]ip route-static 172.1.20.0 24 NULL 0 \[AR1\]ospf \[AR1-ospf-1\]import-route static **验证:** **使用display ip routing-table在每台路由器上查看路由表,可以看到OSPF已经成功引入了上面的5条静态路由** ![](https://i-blog.csdnimg.cn/direct/d38da74b4f4f4385b107e0e438e5bf72.png) **5.** **配置路由发布过滤策略(在AR1上配置IP地址前缀列表a2b,仅允许172.1.17.0/24、172.1.18.0/24和172.1.19.0/24三个网段的路由通过)** \[AR1\]ip ip-prefix a2b index 10 permit 172.1.17.0 24 \[AR1\]ip ip-prefix a2b index 20 permit 172.1.18.0 24 \[AR1\]ip ip-prefix a2b index 30 permit 172.1.19.0 24 **调用前面创建的IP地址前缀列表a2b对发布的静态路由进行过滤** \[AR1\]ospf \[AR1-ospf-1\]filter-policy ip-prefix a2b export static **验证:** **使用display ip routing-table在除AR1的每台路由器上查看路由表,可以看到每台路由器仅接收到列表a2b中定义的3条路由** ![](https://i-blog.csdnimg.cn/direct/b8717002a8da4bd396d3719840ee332c.png) **6.** **配置路由器接收过滤策略(在AR3上配置一个IP地址前缀列表in,仅允许接收172.1.18.0/24的路由)** \[AR3\]ip ip-prefix in index 10 permit 172.1.18.0 24 \[AR3\]ospf \[AR3-ospf-1\]filter-policy ip-prefix in import **验证:** **使用display ip routing-table在AR3路由器上查看路由表,可以看到AR3路由器仅接收到列表in中定义的1条路由** ![](https://i-blog.csdnimg.cn/direct/4c8d77525f0d497d9c7f6bbc6b81b3e4.png)

相关推荐
全栈工程师修炼指南几秒前
Nginx | stream 四层反向代理:SSL、PREREAD 阶段模块指令浅析与实践
运维·网络·网络协议·nginx·ssl
小镇敲码人2 分钟前
深入剖析华为CANN框架下的Ops-CV仓库:从入门到实战指南
c++·python·华为·cann
M1582276905516 分钟前
TCP转LORA产品说明及应用案例
网络·网络协议·tcp/ip
旖旎夜光20 分钟前
Linux(13)(中)
linux·网络
来可电子CAN青年34 分钟前
CAN总线远距离传输老断网?Fx灯不闪别慌,这几招让你的通信“稳如泰山”!
网络
独行soc35 分钟前
2026年渗透测试面试题总结-18(题目+回答)
android·网络·安全·web安全·渗透测试·安全狮
云小逸38 分钟前
【nmap源码解析】Nmap OS识别核心模块深度解析:osscan2.cc源码剖析(1)
开发语言·网络·学习·nmap
果粒蹬i1 小时前
【HarmonyOS】DAY7:鸿蒙跨平台 Tab 开发问题与列表操作难点深度复盘
华为·harmonyos
自不量力的A同学1 小时前
Solon AI v3.9 正式发布:全能 Skill 爆发
java·网络·人工智能
威迪斯特1 小时前
CentOS图形化操作界面:理论解析与实践指南
linux·运维·centos·组件·图形化·桌面·xserver