拓扑图

 

BGP基础配置_第1张图片

实验过程

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)#ip add 172.16.1.1 255.255.255.0 second

R1(config-if)#ip add 172.16.2.1 255.255.255.0 second

R1(config-if)#ip add 172.16.3.1 255.255.255.0 second

R1(config-if)#exit

R1(config)#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

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 f0/0

R2(config-if)#no shut

R2(config-if)#ip add 172.16.255.2 255.255.255.252

R2(config-if)#exit

R2(config)#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

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 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)#int lo0

R3(config-if)#ip add 192.168.0.1 255.255.255.0

R3(config-if)#ip add 192.168.1.1 255.255.255.0 second

R3(config-if)#ip add 192.168.2.1 255.255.255.0 second

R3(config-if)#ip add 192.168.3.1 255.255.255.0 second

R3(config-if)#exit

4.       R1BGP配置

R1(config)#router bgp 64512  //启动BGP路由协议

R1(config-router)#nei 172.16.255.2 remote-as 64512 //指定邻居

R1(config-router)#network 172.16.0.0 mask 255.255.255.0  //宣告网段

R1(config-router)#network 172.16.1.0 mask 255.255.255.0

R1(config-router)#network 172.16.2.0 mask 255.255.255.0

R1(config-router)#network 172.16.3.0 mask 255.255.255.0

R1(config-router)#network 172.16.255.0 mask 255.255.255.252

R1(config-router)#end

5.       R2BGP配置

R2(config)#router bgp 64512

R2(config-router)#nei 172.16.255.1 remote-as 64512

R2(config-router)#nei 10.1.255.2 remote-as 64513

R2(config-router)#network 172.16.255.0 mask 255.255.255.252

R2(config-router)#network 10.1.255.0 mask 255.255.255.252

R2(config-router)#end

6.       R3BGP配置

R3(config)#router bgp 64513

R3(config-router)#nei 10.1.255.1 remote-as 64512

R3(config-router)#network 10.1.255.0 mask 255.255.255.252

R3(config-router)#network 192.168.0.0 mask 255.255.255.0

R3(config-router)#network 192.168.1.0 mask 255.255.255.0

R3(config-router)#network 192.168.2.0 mask 255.255.255.0

R3(config-router)#network 192.168.3.0 mask 255.255.255.0

R3(config-router)#end

7.       查看BGP邻居

R2#show ip bgp summary

BGP router identifier 2.2.2.2, local AS number 64512

BGP table version is 27, main routing table version 27

10 network entries using 1170 bytes of memory

12 path entries using 624 bytes of memory

4/3 BGP path/bestpath attribute entries using 496 bytes of memory

1 BGP AS-PATH entries using 24 bytes of memory

0 BGP route-map cache entries using 0 bytes of memory

0 BGP filter-list cache entries using 0 bytes of memory

BGP using 2314 total bytes of memory

BGP activity 13/3 prefixes, 15/3 paths, scan interval 60 secs

 

Neighbor  V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd

10.1.255.2 4     64513      61      72      27   0   0 00:54:14       5

172.16.255.1 4   64512        60      76       27  0    0 00:55:29     5

8.       查看BGP

R2#show ip bgp

BGP table version is 27, 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

*  10.1.255.0/30    10.1.255.2               0          0 64513 i

*>                  0.0.0.0                0           32768 i

r>i172.16.0.0/24    172.16.255.1             0    100      0 i

r>i172.16.1.0/24    172.16.255.1             0    100      0 i

r>i172.16.2.0/24    172.16.255.1             0    100      0 i

r>i172.16.3.0/24    172.16.255.1             0    100      0 i

*> 172.16.255.0/30  0.0.0.0                  0         32768 i

* i                 172.16.255.1            0    100      0 i

*> 192.168.0.0      10.1.255.2               0             0 64513 i

*> 192.168.1.0      10.1.255.2               0             0 64513 i

*> 192.168.2.0      10.1.255.2               0             0 64513 i

*> 192.168.3.0      10.1.255.2               0             0 64513 i

9.       查看路由表

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, 5 subnets, 2 masks

C       172.16.255.0/30 is directly connected, FastEthernet0/0

C       172.16.0.0/24 is directly connected, Loopback0

C       172.16.1.0/24 is directly connected, Loopback0

C       172.16.2.0/24 is directly connected, Loopback0

C       172.16.3.0/24 is directly connected, Loopback0

     10.0.0.0/30 is subnetted, 1 subnets

B       10.1.255.0 [200/0] via 172.16.255.2, 00:10:36

B    192.168.0.0/24 [200/0] via 10.1.255.2, 00:10:30

B    192.168.1.0/24 [200/0] via 10.1.255.2, 00:10:31

B    192.168.2.0/24 [200/0] via 10.1.255.2, 00:10:31

B    192.168.3.0/24 [200/0] via 10.1.255.2, 00:10:31

10.   测试连通性

R1#ping 172.16.0.1 source lo0

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 172.16.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 = 1/2/4 ms