<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 12.0.0.1 24
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 13.0.0.1 24
[Huawei-GigabitEthernet0/0/1]int loop 0
[Huawei-LoopBack0]ip add 1.1.1.1 32
[Huawei-LoopBack0]q
[Huawei]ip route-static 2.2.2.2 32 12.0.0.2
[Huawei]ip route-static 3.3.3.3 32 13.0.0.3
[Huawei]bgp 100
[Huawei-bgp]router-id 1.1.1.1
[Huawei-bgp]peer 2.2.2.2 as-number 200
[Huawei-bgp]peer 3.3.3.3 as-number 200
[Huawei-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[Huawei-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[Huawei-bgp]peer 2.2.2.2 ebgp-max-hop 2
[Huawei-bgp]peer 3.3.3.3 ebgp-max-hop 2
[Huawei-bgp]net 1.1.1.1 32
[Huawei-bgp]net 2.2.2.2 32
[Huawei-bgp]net 3.3.3.3 32
[Huawei-bgp]q
[Huawei]ping -a 1.1.1.1 5.5.5.5
PING 5.5.5.5: 56 data bytes, press CTRL_C to break
Reply from 5.5.5.5: bytes=56 Sequence=1 ttl=253 time=30 ms
Reply from 5.5.5.5: bytes=56 Sequence=2 ttl=253 time=20 ms
Reply from 5.5.5.5: bytes=56 Sequence=3 ttl=253 time=30 ms
Reply from 5.5.5.5: bytes=56 Sequence=4 ttl=253 time=40 ms
Reply from 5.5.5.5: bytes=56 Sequence=5 ttl=253 time=30 ms
--- 5.5.5.5 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/30/40 ms
<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 12.0.0.2 24
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 24.0.0.2 24
[Huawei-GigabitEthernet0/0/1]int loop0
[Huawei-LoopBack0]ip add 2.2.2.2 32
[Huawei-LoopBack0]q
[Huawei]ip route-static 1.1.1.1 32 12.0.0.1
[Huawei]ospf
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]net 2.2.2.2 0.0.0.0
[Huawei-ospf-1-area-0.0.0.0]net 24.0.0.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]q
[Huawei-ospf-1]q
[Huawei]bgp 200
[Huawei-bgp]router-id 2.2.2.2
[Huawei-bgp]peer 1.1.1.1 as-number 100
[Huawei-bgp]peer 4.4.4.4 as-number 200
[Huawei-bgp]peer 3.3.3.3 as-number 200
[Huawei-bgp]peer 1.1.1.1 connect-interface LoopBack 0
[Huawei-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[Huawei-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[Huawei-bgp]peer 1.1.1.1 ebgp-max-hop 2
[Huawei-bgp]peer 3.3.3.3 next-hop-local
[Huawei-bgp]peer 4.4.4.4 next-hop-local
[Huawei-bgp]net 1.1.1.1 32
[Huawei-bgp]net 2.2.2.2 32
[Huawei-bgp]net 3.3.3.3 32
[Huawei-bgp]net 4.4.4.4 32
<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 13.0.0.3 24
[Huawei-GigabitEthernet0/0/1]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 34.0.0.3 24
[Huawei-GigabitEthernet0/0/0]int loop0
[Huawei-LoopBack0]ip add 3.3.3.3 32
[Huawei-LoopBack0]q
[Huawei]ip route-static 1.1.1.1 32 13.0.0.1
[Huawei]ospf
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]net 3.3.3.3 0.0.0.0
[Huawei-ospf-1-area-0.0.0.0]net 34.0.0.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]q
[Huawei-ospf-1]q
[Huawei]bgp 200
[Huawei-bgp]router-id 3.3.3.3
[Huawei-bgp]peer 1.1.1.1 as-number 100
[Huawei-bgp]peer 4.4.4.4 as-number 200
[Huawei-bgp]peer 2.2.2.2 as-number 200
[Huawei-bgp]peer 1.1.1.1 connect-interface LoopBack 0
[Huawei-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[Huawei-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[Huawei-bgp]peer 1.1.1.1 ebgp-max-hop 2
[Huawei-bgp]peer 4.4.4.4 next-hop-local
[Huawei-bgp]peer 2.2.2.2 next-hop-local
[Huawei-bgp]net 1.1.1.1 32
[Huawei-bgp]net 2.2.2.2 32
[Huawei-bgp]net 3.3.3.3 32
[Huawei-bgp]net 4.4.4.4 32
<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 34.0.0.4 24
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 24.0.0.4 24
[Huawei-GigabitEthernet0/0/1]int g0/0/2
[Huawei-GigabitEthernet0/0/2]ip add 45.0.0.4 24
[Huawei-GigabitEthernet0/0/2]int loop0
[Huawei-LoopBack0]ip add 4.4.4.4 32
[Huawei-LoopBack0]q
[Huawei]ip route-static 5.5.5.5 32 45.0.0.5
[Huawei]ospf
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]net 4.4.4.4 0.0.0.0
[Huawei-ospf-1-area-0.0.0.0]net 34.0.0.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]net 24.0.0.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]q
[Huawei-ospf-1]q
[Huawei]bgp 200
[Huawei-bgp]router-id 4.4.4.4
[Huawei-bgp]peer 2.2.2.2 as-number 200
[Huawei-bgp]peer 3.3.3.3 as-number 200
[Huawei-bgp]peer 5.5.5.5 as-number 300
[Huawei-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[Huawei-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[Huawei-bgp]peer 5.5.5.5 connect-interface LoopBack 0
[Huawei-bgp]peer 2.2.2.2 next-hop-local
[Huawei-bgp]peer 3.3.3.3 next-hop-local
[Huawei-bgp]peer 5.5.5.5 ebgp-max-hop 2
[Huawei-bgp]net 2.2.2.2 32
[Huawei-bgp]net 3.3.3.3 32
[Huawei-bgp]net 4.4.4.4 32
[Huawei-bgp]net 5.5.5.5 32
<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]int g 0/0/2
[Huawei-GigabitEthernet0/0/2]ip add 45.0.0.5 24
[Huawei-GigabitEthernet0/0/2]int loop0
[Huawei-LoopBack0]ip add 5.5.5.5 32
[Huawei-LoopBack0]q
[Huawei]ip route-static 4.4.4.4 32 45.0.0.4
[Huawei]bgp 300
[Huawei-bgp]router-id 5.5.5.5
[Huawei-bgp]peer 4.4.4.4 as-number 200
[Huawei-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[Huawei-bgp]peer 4.4.4.4 ebgp-max-hop 2
[Huawei-bgp]net 4.4.4.4 32
[Huawei-bgp]net 5.5.5.5 32
[Huawei]dis bgp routing-table
BGP Local router ID is 1.1.1.1
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 13
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 1.1.1.1/32 0.0.0.0 0 0 i
* 2.2.2.2 0 0 200i
* 3.3.3.3 0 0 200i
*> 2.2.2.2/32 0.0.0.0 0 0 i
* 3.3.3.3 2 0 200i
2.2.2.2 0 0 200i
*> 3.3.3.3/32 0.0.0.0 0 0 i
* 2.2.2.2 2 0 200i
3.3.3.3 0 0 200i
*> 4.4.4.4/32 2.2.2.2 1 0 200i
* 3.3.3.3 1 0 200i
*> 5.5.5.5/32 2.2.2.2 0 200i
* 3.3.3.3 0 200i
[Huawei]dis bgp routing-table
BGP Local router ID is 4.4.4.4
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 14
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 1.1.1.1/32 2.2.2.2 0 100 0 i
* i 3.3.3.3 0 100 0 i
*> 2.2.2.2/32 0.0.0.0 1 0 i
* i 3.3.3.3 2 100 0 i
i 2.2.2.2 0 100 0 i
*> 3.3.3.3/32 0.0.0.0 1 0 i
* i 2.2.2.2 2 100 0 i
i 3.3.3.3 0 100 0 i
*> 4.4.4.4/32 0.0.0.0 0 0 i
* i 2.2.2.2 1 100 0 i
* i 3.3.3.3 1 100 0 i
* 5.5.5.5 0 0 300i
*> 5.5.5.5/32 0.0.0.0 0 0 i
5.5.5.5 0 0 300i
这时候,我们可以看到,从R1到R4走的是R2,R4到R1走的也是R2,我们需要择路。
[Huawei]route-policy as permit node 10
Info: New Sequence of this List.
[Huawei-route-policy]apply as-path 123 123 additive
[Huawei-route-policy]q
[Huawei]bgp 100
[Huawei-bgp]peer 2.2.2.2 route-policy as import
[Huawei-bgp]q
[Huawei]q
<Huawei>refresh bgp all import
[Huawei]route-policy lop permit node 10
Info: New Sequence of this List.
[Huawei-route-policy]apply local-preference 222
[Huawei-route-policy]q
[Huawei]bgp 200
[Huawei-bgp]peer 4.4.4.4 route-policy lop export
[Huawei-bgp]q
[Huawei]q
<Huawei>refresh bgp all export
<Huawei>dis bgp routing-table
BGP Local router ID is 1.1.1.1
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 13
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 1.1.1.1/32 0.0.0.0 0 0 i
* 3.3.3.3 0 0 200i
* 2.2.2.2 0 0 123 123 20
0i
*> 2.2.2.2/32 0.0.0.0 0 0 i
* 3.3.3.3 2 0 200i
2.2.2.2 0 0 123 123 20
0i
*> 3.3.3.3/32 0.0.0.0 0 0 i
* 2.2.2.2 2 0 123 123 20
0i
3.3.3.3 0 0 200i
*> 4.4.4.4/32 3.3.3.3 1 0 200i
* 2.2.2.2 1 0 123 123 20
0i
*> 5.5.5.5/32 3.3.3.3 0 200i
* 2.2.2.2 0 123 123 20
0i
[Huawei]dis bgp routing-table
BGP Local router ID is 4.4.4.4
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 14
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 1.1.1.1/32 3.3.3.3 0 222 0 i
* i 2.2.2.2 0 100 0 i
*>i 2.2.2.2/32 3.3.3.3 2 222 0 i
* 0.0.0.0 1 0 i
i 2.2.2.2 0 100 0 i
*> 3.3.3.3/32 0.0.0.0 1 0 i
* i 2.2.2.2 2 100 0 i
i 3.3.3.3 0 222 0 i
*>i 4.4.4.4/32 3.3.3.3 1 222 0 i
* 0.0.0.0 0 0 i
* i 2.2.2.2 1 100 0 i
* 5.5.5.5 0 0 300i
*> 5.5.5.5/32 0.0.0.0 0 0 i
5.5.5.5 0 0 300i