It's often useful to conditionally advertise some routes to upstream neighbors—particularly if you are trying to control which link is crossed by traffic destined to a particular network. (Refer to "Case Study: Dual-Homed Connections to the Internet" for an example.)
BGP has the capability to conditionally advertise routes; look at Figure 8-8 and work through the example that follows.
In this case, you want to advertise 172.28.23.0/24 to Router B as long as that link is up, but if it fails, you want to advertise this route to Router A from Router C.
Here, you would build a normal eBGP neighbor relationship between Routers B and D and a normal iBGP neighbor relationship between Routers C and D. The only magic is on Router C. Take a look at Router C's configuration:
C#sho running-config
Building configuration…
….
!
router ospf 100
network 0.0.0.0 255.255.255.255 area 0
!
router bgp 100
network 172.28.23.0 mask 255.255.255.0
neighbor 10.1.1.1 remote-as 200
neighbor 10.1.1.1 distribute-list 20 out
neighbor 10.1.1.1 advertise-map toadvertise non-exist-map ifnotexist
neighbor 10.1.2.2 remote-as 100
!
access-list 10 permit 172.28.23.0 0.0.0.255
access-list 20 deny 10.1.3.0 0.0.0.255
access-list 20 permit any
access-list 30 permit 10.1.3.0 0.0.0.255
….
route-map ifnotexist permit 10
match ip address 30
!
route-map ifnotexist deny 20
!
route-map toadvertise permit 10
match ip address 10
!
The magic is in the neighbor 10.1.1.1 advertise-map toadvertise non-exist-map ifnotexist configuration statement. This tells BGP to advertise those networks permitted by the route map toadvertise if the networks matched by route map ifnotexist aren't in the BGP table.
To see if it works, you need to shut down the link from Router B to Router D and see if Router A picks the 172.28.23.0/24 network up in its routing table:
D(config)#int s1
D(config-if)#shut
D(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1, changed state to down
%LINK-5-CHANGED: Interface Serial1, changed state to administratively down
A>sho ip route
….
172.28.0.0/16 is subnetted, 1 subnets
B 172.28.23.0 [20/60] via 10.1.1.2, 00:00:25
….
18.220.163.91