拓扑图

 

实验过程

 

1.       R1的预配置

Router>en

Router#config t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#no ip domain-lookup

Router(config)#line console 0

Router(config-line)#no exec-timeout

Router(config-line)#loggin syn

Router(config-line)#exit

Router(config)#host R1

R1(config)#int lo0

R1(config-if)#ip add 172.16.0.1 255.255.255.0

R1(config-if)#int lo1

R1(config-if)#ip add 172.16.1.1 255.255.255.0

R1(config-if)#int f0/0

R1(config-if)#no shut

R1(config-if)#ip add 172.16.255.1 255.255.255.252

R1(config-if)#exit

R1(config)#

R1(config)#router rip

R1(config-router)#version 2

R1(config-router)#no auto

R1(config-router)#net  172.16.0.0

R1(config-router)#end

2.       R2的预配置

Router>en

Router#config t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#no ip domain-lookup

Router(config)#line console 0

Router(config-line)#no exec-timeout

Router(config-line)#loggin syn

Router(config-line)#exit

Router(config)#host R2

R2(config)#int lo0

R2(config-if)#ip add 172.16.16.1 255.255.255.0

R2(config-if)#int f0/0

R2(config-if)#no shut

R2(config-if)#ip add 172.16.255.2 255.255.255.252

R2(config-if)#int s1/0

R2(config-if)#no shut

R2(config-if)#ip add 10.1.255.1 255.255.255.252

R2(config-if)#exit

R2(config)#

R2(config)#router rip

R2(config-router)#version 2

R2(config-router)#no auto

R2(config-router)#net 172.16.0.0

R2(config-router)#exit

R2(config)#ip route 192.168.0.0 255.255.255.0 10.1.255.2

3.       R3的预配置

Router>en

Router#config t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#no ip domain-lookup

Router(config)#line console 0

Router(config-line)#no exec-timeout

Router(config-line)#loggin syn

Router(config-line)#exit

Router(config)#host R3

R3(config)#int lo0

R3(config-if)#ip add 192.168.0.1 255.255.255.0

R3(config-if)#int lo1

R3(config-if)#ip add 192.168.1.1 255.255.255.0

R3(config-if)#int s1/0

R3(config-if)#no shut

R3(config-if)#ip add 10.1.255.2 255.255.255.252

R3(config-if)#exit

R3(config)#ip route 172.16.16.0 255.255.255.0 10.1.255.1

4.       配置R1BGP

R1(config)#router bgp 100

R1(config-router)#nei 172.16.16.1 remote-as 100

R1(config-router)#nei 172.16.16.1 update-source lo0  //指定更新源为回环口

R1(config-router)#net 172.16.0.0 mask 255.255.255.0

R1(config-router)#net 172.16.1.0 mask 255.255.255.0

R1(config-router)#net 172.16.255.0 mask 255.255.255.252

R1(config-router)#end

5.       配置R2BGP

R2(config)#router bgp 100

R2(config-router)#nei 172.16.0.1 remote-as 100

R2(config-router)#nei 172.16.0.1 update-source lo0

R2(config-router)#nei 172.16.0.1 next-hop-self  //指定下一跳为自己

R2(config-router)#nei 192.168.0.1 remote-as 200

R2(config-router)#nei 192.168.0.1 update-source lo0

R2(config-router)#nei 192.168.0.1 next-hop-self

R2(config-router)#nei 192.168.0.1 ebgp-m 2  //打开ebgp多跳

R2(config-router)#net 172.16.255.0 mask 255.255.255.252

R2(config-router)#net 10.1.255.0 mask 255.255.255.252

R2(config-router)#net 172.16.16.0 mask 255.255.255.0

R2(config-router)#end

6.       配置R3BGP

R3(config)#router bgp 200

R3(config-router)#nei 172.16.16.1 remote-as 100

R3(config-router)#nei 172.16.16.1 update-source lo0

R3(config-router)#nei 172.16.16.1 ebgp-m 2

R3(config-router)#net 192.168.0.0 mask 255.255.255.0

R3(config-router)#net 192.168.1.0 mask 255.255.255.0

R3(config-router)#net 10.1.255.0 mask 255.255.255.252

R3(config-router)#end

7.       查看BGP信息

R1#show ip bgp

BGP table version is 9, local router ID is 172.16.1.1

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

*>i10.1.255.0/30    172.16.16.1              0    100      0 i

*> 172.16.0.0/24    0.0.0.0                  0         32768 i

*> 172.16.1.0/24    0.0.0.0                  0         32768 i

r>i172.16.16.0/24   172.16.16.1              0    100      0 i

* i172.16.255.0/30  172.16.16.1              0    100      0 i

*>                  0.0.0.0               0         32768 i

*>i192.168.0.0      172.16.16.1              0    100      0 200 i

*>i192.168.1.0      172.16.16.1              0    100      0 200 i

8.       查看路由表

R1#show 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

 

     172.16.0.0/16 is variably subnetted, 4 subnets, 2 masks

C       172.16.255.0/30 is directly connected, FastEthernet0/0

R       172.16.16.0/24 [120/1] via 172.16.255.2, 00:00:20, FastEthernet0/0

C       172.16.0.0/24 is directly connected, Loopback0

C       172.16.1.0/24 is directly connected, Loopback1

     10.0.0.0/30 is subnetted, 1 subnets

B       10.1.255.0 [200/0] via 172.16.16.1, 00:08:42

B    192.168.0.0/24 [200/0] via 172.16.16.1, 00:08:42

B    192.168.1.0/24 [200/0] via 172.16.16.1, 00:08:42

9.       测试连通性

R1#ping 192.168.0.1 source lo0

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.0.1, timeout is 2 seconds:

Packet sent with a source address of 172.16.0.1

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 44/69/100 ms

R1#ping 192.168.0.1 source lo1

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.0.1, timeout is 2 seconds:

Packet sent with a source address of 172.16.1.1

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 36/49/68 ms