要求:对于as2内部的用户,去往1.1.0.0/24和1.1.2.0/24默认从r2走,去往1.1.2.0/24和1.1.3.0/24默认从r3走,并且保证r2或r3任意一台down掉,网络仍然那保持连通性。
option 1就是使用最长匹配的原则。r1往r3宣告一条关于1.1.0.0/24和1.1.1.0/24的汇总1.1.0.0/23,那么as 2内的用户去往1.1.0.0/24和1.1.1.0/24默认就会走r2了。
R1
hostname R1
!
interface Loopback0
ip address 1.1.0.1 255.255.255.0
!
interface Loopback1
ip address 1.1.1.1 255.255.255.0
!
interface Loopback2
ip address 1.1.2.1 255.255.255.0
!
interface Loopback3
ip address 1.1.3.1 255.255.255.0
!
interface FastEthernet0/0
ip address 192.168.12.1 255.255.255.0
speed 100
full-duplex
!
interface FastEthernet0/1
ip address 192.168.13.1 255.255.255.0
speed 100
full-duplex
!
router bgp 10
no synchronization
bgp router-id 1.1.1.1
bgp log-neighbor-changes
network 1.1.0.0 mask 255.255.255.0
network 1.1.1.0 mask 255.255.255.0
network 1.1.2.0 mask 255.255.255.0
network 1.1.3.0 mask 255.255.255.0
aggregate-address 1.1.0.0 255.255.254.0
aggregate-address 1.1.2.0 255.255.254.0
neighbor 192.168.12.2 remote-as 20
neighbor 192.168.12.2 soft-reconfiguration inbound
neighbor 192.168.12.2 route-map r2 out
neighbor 192.168.13.3 remote-as 20
neighbor 192.168.13.3 soft-reconfiguration inbound
neighbor 192.168.13.3 route-map r3 out
no auto-summary
!
ip prefix-list detail1 seq 5 permit 1.1.0.0/24
ip prefix-list detail1 seq 10 permit 1.1.1.0/24
!
ip prefix-list detail2 seq 5 permit 1.1.2.0/24
ip prefix-list detail2 seq 10 permit 1.1.3.0/24
!
ip prefix-list summary1 seq 5 permit 1.1.0.0/23
!
ip prefix-list summary2 seq 5 permit 1.1.2.0/23
!
route-map r2 deny 10
match ip address prefix-list detail2
!
route-map r2 deny 20
match ip address prefix-list summary1
!
route-map r2 permit 30
!
route-map r3 deny 10
match ip address prefix-list detail1
!
route-map r3 deny 20
match ip address prefix-list summary2
!
route-map r3 permit 30
!
end
R2
hostname R2
!
interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.12.2 255.255.255.0
speed 100
full-duplex
!
interface FastEthernet0/1
ip address 192.168.23.2 255.255.255.0
speed 100
full-duplex
!
router bgp 20
no synchronization
bgp router-id 2.2.2.2
bgp log-neighbor-changes
network 192.168.23.0
neighbor 192.168.12.1 remote-as 10
neighbor 192.168.12.1 soft-reconfiguration inbound
neighbor 192.168.23.3 remote-as 20
neighbor 192.168.23.3 next-hop-self
neighbor 192.168.23.3 soft-reconfiguration inbound
no auto-summary
!
end
R3
hostname R3
!
interface Loopback0
ip address 3.3.3.3 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.13.3 255.255.255.0
speed 100
full-duplex
!
interface FastEthernet0/1
ip address 192.168.23.3 255.255.255.0
speed 100
full-duplex
!
router bgp 20
no synchronization
bgp router-id 3.3.3.3
bgp log-neighbor-changes
network 192.168.23.0
neighbor 192.168.13.1 remote-as 10
neighbor 192.168.13.1 soft-reconfiguration inbound
neighbor 192.168.23.2 remote-as 20
neighbor 192.168.23.2 next-hop-self
neighbor 192.168.23.2 soft-reconfiguration inbound
no auto-summary
!
end
verification
R2#sho ip route 1.1.3.0
Routing entry for 1.1.3.0/24
Known via "bgp 20", distance 200, metric 0
Tag 10, type internal
Lastupdatefrom 192.168.23.3 00:33:57 ago
Routing Descriptor Blocks:
* 192.168.23.3, from 192.168.23.3, 00:33:57 ago
Route metric is 0, traffic share count is 1
AS Hops 1
Route tag 10
R2#tra
R2#traceroute 1.1.3.1 pro
R2#traceroute 1.1.3.1 probe 1
Type escape sequence to abort.
Tracing the route to 1.1.3.1
1 192.168.23.3 128 msec
2 192.168.13.1 300 msec
R3#sho ip route 1.1.1.0
Routing entry for 1.1.1.0/24
Known via "bgp 20", distance 200, metric 0
Tag 10, type internal
Lastupdatefrom 192.168.23.2 00:33:49 ago
Routing Descriptor Blocks:
* 192.168.23.2, from 192.168.23.2, 00:33:49 ago
Route metric is 0, traffic share count is 1
AS Hops 1
Route tag 10
R3#tra
R3#traceroute 1.1.1.1 pro
R3#traceroute 1.1.1.1 probe 1
Type escape sequence to abort.
Tracing the route to 1.1.1.1
1 192.168.23.2 48 msec
2 192.168.12.1 360 msec