<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

R1(config)#int s2/1
R1(config-if)#ip add <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />12.0.0.1 255.255.255.0
R1(config-if)#no shu
R1(config-if)#int f0/0
R1(config-if)#ip add 21.0.0.1 255.255.255.0
R1(config-if)#no shu
R1(config-if)#int lo0
R1(config-if)#ip add 1.1.1.1 255.255.255.255

 

R1(config)#router ospf 1
R1(config-router)#router-id 1.1.1.1
R1(config-router)#net 12.0.0.0 0.0.0.255 a 0
R1(config-router)#net 21.0.0.0 0.0.0.255 a 0
R1(config-router)#net 1.1.1.1 0.0.0.0 a 0
R1(config-router)#exit
R1(config)#router bgp 100
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#no syn
R1(config-router)#no au
R1(config-router)#nei 12.0.0.2 remote-as 200
R1(config-router)#nei 21.0.0.2 remote-as 200
R1(config-router)#net 1.1.1.1 mask 255.255.255.255
R1(config-if)#do clear ip bgp * s o

 

 

 

R2(config)#int s2/1
R2(config-if)#ip add 12.0.0.2 255.255.255.0
R2(config-if)#no shu
R2(config-if)#int f0/0
R2(config-if)#ip add 21.0.0.2 255.255.255.0
R2(config-if)#no shu
R2(config-if)#exit
R2(config)#router ospf 1
R2(config-router)#router-id 2.2.2.2
R2(config-router)#net 12.0.0.0 0.0.0.255 a 0
R2(config-router)#net 21.0.0.0 0.0.0.255 a 0
R2(config-router)#exit
R2(config)#router bgp 200
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#no syn
R2(config-router)#no au
R2(config-router)#nei 12.0.0.1 remote-as 100
R2(config-router)#nei 21.0.0.1 remote-as 100

 

R2(config-router)#do sh ip bgp sum

 

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
12.0.0.1        4   100       7       6        2    0    0 00:02:41        1
21.0.0.1        4   100       5       5        2    0    0 00:00:06        1

 

R2(config-router)#do sh ip bgp
BGP table version is 2, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path
*  1.1.1.1/32       21.0.0.1                 0             0 100 i
*>                  12.0.0.1                 0             0 100 i
R2(config-router)#network 1.1.1.1 mask 255.255.255.255 backdoor

R2(config-router)#do sh ip bgp
BGP table version is 3, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path
r  1.1.1.1/32       21.0.0.1                 0             0 100 i
r>                  12.0.0.1                 0             0 100 i
R2(config-router)#do sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

 

Gateway of last resort is not set

 

     1.0.0.0/32 is subnetted, 1 subnets
O       1.1.1.1 [110/2] via 21.0.0.1, 00:02:25, FastEthernet0/0
     21.0.0.0/24 is subnetted, 1 subnets
C       21.0.0.0 is directly connected, FastEthernet0/0
     12.0.0.0/24 is subnetted, 1 subnets
C       12.0.0.0 is directly connected, Serial2/1
R2(config-router)#no network 1.1.1.1 mask 255.255.255.255 backdoor

R2(config-router)#do sh ip bgp                                    
BGP table version is 4, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path
*  1.1.1.1/32       21.0.0.1                 0             0 100 i
*>                  12.0.0.1                 0             0 100 i
R2(config-router)#do sh ip route                                  
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

 

Gateway of last resort is not set

 

     1.0.0.0/32 is subnetted, 1 subnets
B       1.1.1.1 [20/0] via 12.0.0.1, 00:00:13
     21.0.0.0/24 is subnetted, 1 subnets
C       21.0.0.0 is directly connected, FastEthernet0/0
     12.0.0.0/24 is subnetted, 1 subnets
C       12.0.0.0 is directly connected, Serial2/1

 

 

R2(config-router)#do  ping 1.1.1.1          

 

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 24/84/152 ms
R2(config-router)#
注:
R2(config-router)#network 1.1.1.1 mask 255.255.255.255 backdoor

R2(config-router)# no network 1.1.1.1 mask 255.255.255.255 backdoor

注意观察 R2 ip 路由变化,还有 R2 bgp 路由变化。

 

 

 

这是没有建立bgpR1R2之间跑完ospfR2上学到的ip路由。

R2(config)#do sh ip route

Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1, E2 - OSPF external type 2

       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2

       ia - IS-IS inter area, * - candidate default, U - per-user static route

       o - ODR, P - periodic downloaded static route

 

Gateway of last resort is not set

 

     1.0.0.0/32 is subnetted, 1 subnets

O       1.1.1.1 [110/2] via 21.0.0.1, 00:00:06, FastEthernet0/0

     21.0.0.0/24 is subnetted, 1 subnets

C       21.0.0.0 is directly connected, FastEthernet0/0

     12.0.0.0/24 is subnetted, 1 subnets

C       12.0.0.0 is directly connected, Serial2/1