R1:
[Huawei]int GigabitEthernet 0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 10.0.12.1 24
[Huawei-GigabitEthernet0/0/0]quit
[Huawei]int GigabitEthernet 0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 10.0.13.1 24
[Huawei-GigabitEthernet0/0/1]int loop0
[Huawei-LoopBack0]ip address 1.1.1.1 32
[Huawei-LoopBack0]quit
R2:
[Huawei]int GigabitEthernet 0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 10.0.12.2 24
[Huawei-GigabitEthernet0/0/0]quit
[Huawei]int GigabitEthernet 0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 10.0.24.2 24
[Huawei-GigabitEthernet0/0/1]int loop0
[Huawei-LoopBack0]ip address 2.2.2.2 32
[Huawei-LoopBack0]quit
R3:
[Huawei]int GigabitEthernet 0/0/0
[Huawei-GigabitEthernet0/0/0]ip ad
[Huawei-GigabitEthernet0/0/0]ip address 10.0.13.3 24
[Huawei-GigabitEthernet0/0/0]quit
[Huawei]int GigabitEthernet 0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 10.0.34.3 24
[Huawei-GigabitEthernet0/0/1]int loop0
[Huawei-LoopBack0]ip address 3.3.3.3 32
[Huawei-LoopBack0]quit
R4:
[Huawei]int GigabitEthernet 0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 10.0.24.4 24
[Huawei-GigabitEthernet0/0/0]quit
[Huawei]int GigabitEthernet 0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 10.0.34.4 24
[Huawei-GigabitEthernet0/0/1]int loop0
[Huawei-LoopBack0]ip address 4.4.4.4 32
[Huawei-LoopBack0]quit
R2:
[Huawei]ospf 1
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]network 10.0.24.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
R3:
[Huawei]ospf 1
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]network 10.0.34.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
R4:
[Huawei]ospf 1
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]network 10.0.24.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]network 10.0.34.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]network 4.4.4.4 0.0.0.0
至此,R1、R3、R4能互相ping通如下图所示
R1:
[Huawei]bgp 100
[Huawei-bgp]router-id 1.1.1.1
[Huawei-bgp]peer 10.0.12.2 as-number 200
[Huawei-bgp]peer 10.0.13.3 as-number 200
[Huawei-bgp]network 1.1.1.1 32
R2:
[Huawei]bgp 200
[Huawei-bgp]router-id 2.2.2.2
[Huawei-bgp]peer 10.0.12.1 as-number 100
[Huawei-bgp]peer 10.0.24.4 as-number 200
[Huawei-bgp]peer 10.0.24.4 next-hop-local
[Huawei-bgp]import-route ospf 1
R3:
[Huawei]bgp 200
[Huawei-bgp]route-select
[Huawei-bgp]router-id 3.3.3.3
[Huawei-bgp]peer 10.0.13.1 as-number 100
[Huawei-bgp]peer 10.0.34.4 as-number 200
[Huawei-bgp]peer 10.0.34.4 next-hop-local
[Huawei-bgp]import-route ospf 1
R4:
[Huawei]bgp 200
[Huawei-bgp]router-id 4.4.4.4
[Huawei-bgp]peer 10.0.24.2 as-number 200
[Huawei-bgp]peer 10.0.34.3 as-number 200
[Huawei-bgp]network 4.4.4.4 32
查看R2中路由表如下图所示
题目要求R1到R4路由优先选择R1->R2->R4 ,R4到R1的路由优先选择R4->R3->R1
R3:
[Huawei]route-policy lop permit node 10
[Huawei-route-policy]apply local-preference 222
[Huawei-route-policy]quit
[Huawei]bgp 200
[Huawei-bgp]peer 10.0.34.4 route-policy lop export
[Huawei-bgp]quit
[Huawei]quit
R2:
[Huawei]route-policy lop permit node 10
[Huawei-route-policy]apply local-preference 222
[Huawei-route-policy]quit
[Huawei]bgp 200
[Huawei-bgp]peer 10.0.12.1 route-policy lop export
[Huawei-bgp]quit
下面通过R4ping R1同时在R1的GE0/0/0和GE0/0/1分别抓包,结果如下:(左框为0端口,右为1端口)
由上图可知,显然R4 ping R1时走的是R4->R3->R1路径。