步骤一:配置三台路由器接口使其连通。
 
R1的配置
R1(config)# interface Loopback0
R1(config-if)# ip address 1.1.1.1 255.255.255.0
R1(config)# interface Loopback1
R1(config-if)# ip address 2.2.2.2 255.255.255.0
R1(config)# interface s0
R1(config-if)# ip address 10.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#clock rate 64000
 
R2的配置
R2(config)#interface Loopback0
R2(config-if)# ip address 3.3.3.3 255.255.255.0
R2(config)#interface Loopback1
R2(config-if)# ip address 4.4.4.4 255.255.255.0
R2(config)#interface Serial0
R2(config-if)# ip address 20.1.1.1 255.255.255.0
R2(config-if)#no shutdown
R2(config)#interface Serial1
R2(config-if)# ip address 10.1.1.2 255.255.255.0
R2(config-if)#no shutdown
 
R3的配置
R3(config)#interface Loopback0
R3(config-if)# ip address 5.5.5.5 255.255.255.0
R3(config)#interface Loopback1
R3(config-if)# ip address 6.6.6.6 255.255.255.0
R3(config)#interface Serial1
R3(config-if)# ip address 20.1.1.2 255.255.255.0
R3(config-if)#clockrate 64000
R3(config-if)#no shutdown
 
 
步骤二:启用
 
R1的配置
R1(config)#router eigrp 100 à启用eigrp100
R1(config-router)#network 1.1.1.0 0.0.0.255 à发布相应接口
R1(config-router)#network 10.1.1.0 0.0.0.255
R1(config-router)# no auto-summary à关闭自动汇总
 
R1(config)#router bgp 65001 à启用BGP65001
R1(config-router)#no synchronization  à关闭与IGP的同步
R1(config-router)# network 2.2.2.0 mask 255.255.255.0 à发布参与BGP网段
R1(config-router)# network 10.1.1.0 mask 255.255.255.0
R1(config-router)# neighbor 3.3.3.3 remote-as 65001  à指定邻居
R1(config-router)# neighbor 3.3.3.3 update-source Loopback0 à更新源改为loop0接口
R1(config-router)#no auto-summary  à关闭自动汇总
 
R2的配置
R2(config)#router eigrp 100
R2(config-router)# network 3.3.3.0 0.0.0.255
R2(config-router)# network 10.1.1.0 0.0.0.255
R2(config-router)# no auto-summary
 
R2(config)#router bgp 65001
R2(config-router)# no synchronization
R2(config-router)# network 4.4.4.0 mask 255.255.255.0
R2(config-router)# network 10.1.1.0 mask 255.255.255.0
R2(config-router)# neighbor 1.1.1.1 remote-as 65001
R2(config-router)# neighbor 1.1.1.1 update-source Loopback0
R2(config-router)# neighbor 1.1.1.1 next-hop-self  à将自己指定为邻居的下一跳
R2(config-router)# neighbor 5.5.5.5 remote-as 65002  à指定ebgp邻居
R2(config-router)# neighbor 5.5.5.5 ebgp-multihop 255  à设定多跳,默认为1
R2(config-router)# neighbor 5.5.5.5 update-source Loopback0
R2(config-router)# no auto-summary 
 
R3的配置
R3(config)#router bgp 65002
R3(config-router)#network 6.6.6.0 mask 255.255.255.0
R3(config-router)# neighbor 3.3.3.3 remote-as 65001
R3(config-router)# neighbor 3.3.3.3 ebgp-multihop 255
R3(config-router)# neighbor 3.3.3.3 update-source Loopback0
R3(config-router)# no auto-summary
 
 
步骤三:配置静态路由
 
R2(config)# ip route 5.5.5.0 255.255.255.0 20.1.1.2 àR2和R3运行在不同的AS,所以要指静态路由来达到可达性
R3(config)# ip route 3.3.3.0 255.255.255.0 20.1.1.1  à同理
 
 
步骤四:查看路由表
 
R1#sh ip route
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
       i - IS-IS, 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/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
     2.0.0.0/24 is subnetted, 1 subnets
C       2.2.2.0 is directly connected, Loopback1
     3.0.0.0/24 is subnetted, 1 subnets
D       3.3.3.0 [90/2297856] via 10.1.1.2, 00:09:13, Serial0
     4.0.0.0/24 is subnetted, 1 subnets
B       4.4.4.0 [200/0] via 3.3.3.3, 00:07:34  à学来了BGP路由条目
     6.0.0.0/24 is subnetted, 1 subnets
B       6.6.6.0 [200/0] via 3.3.3.3, 00:07:34
     10.0.0.0/24 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, Serial0
 
R2#sh ip route
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
       i - IS-IS, 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/24 is subnetted, 1 subnets
D       1.1.1.0 [90/2297856] via 10.1.1.1, 00:14:09, Serial1
     2.0.0.0/24 is subnetted, 1 subnets
B       2.2.2.0 [200/0] via 1.1.1.1, 00:14:05
     3.0.0.0/24 is subnetted, 1 subnets
C       3.3.3.0 is directly connected, Loopback0
     4.0.0.0/24 is subnetted, 1 subnets
C       4.4.4.0 is directly connected, Loopback1
     20.0.0.0/24 is subnetted, 1 subnets
C       20.1.1.0 is directly connected, Serial0
     5.0.0.0/24 is subnetted, 1 subnets
S       5.5.5.0 [1/0] via 20.1.1.2
     6.0.0.0/24 is subnetted, 1 subnets
B       6.6.6.0 [20/0] via 5.5.5.5, 00:18:07
     10.0.0.0/24 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, Serial1
 
R3#sh ip route
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
       i - IS-IS, 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
 
     2.0.0.0/24 is subnetted, 1 subnets
B       2.2.2.0 [20/0] via 3.3.3.3, 00:18:06
     3.0.0.0/24 is subnetted, 1 subnets
S       3.3.3.0 [1/0] via 20.1.1.1
     4.0.0.0/24 is subnetted, 1 subnets
B       4.4.4.0 [20/0] via 3.3.3.3, 00:22:07
     20.0.0.0/24 is subnetted, 1 subnets
C       20.1.1.0 is directly connected, Serial1
     5.0.0.0/24 is subnetted, 1 subnets
C       5.5.5.0 is directly connected, Loopback0
     6.0.0.0/24 is subnetted, 1 subnets
C       6.6.6.0 is directly connected, Loopback1
     10.0.0.0/24 is subnetted, 1 subnets
B       10.1.1.0 [20/0] via 3.3.3.3, 00:22:09
 
 
步骤五:查看bgp 概要信息
 
R1#sh ip bgp summary
BGP router identifier 2.2.2.2, local AS number 65001
 
Neighbor V AS MsgRcvd MsgSent TblVer  InQ OutQ Up/Down  State/PfxRcd
3.3.3.3   4 65001      13      12        5    0    0 00:08:23        3
 
R2#sh ip bgp summary
BGP router identifier 4.4.4.4, local AS number 65001
 
Neighbor V AS MsgRcvd MsgSent TblVer  InQ OutQ Up/Down  State/PfxRcd
1.1.1.1   4 65001      18      19        5    0    0 00:14:41        2
5.5.5.5   4 65002      22      23        5    0    0 00:18:42        1
 
R3#sh ip bgp summary
BGP router identifier 6.6.6.6, local AS number 65002
 
NeighborV AS MsgRcvd MsgSent TblVer  InQ OutQ Up/Down  State/PfxRcd
3.3.3.3   4 65001      27    26        5    0    0 00:22:36        3
 
 
步骤六:查看bgp邻居
 
R1#sh ip bgp neighbors
BGP neighbor is 3.3.3.3,  remote AS 65001, internal link
  BGP version 4, remote router ID 4.4.4.4
  BGP state = Established, up for 00:10:41  àIBGP邻居已建立
  Last read 00:00:41, hold time is 180, keepalive interval is 60 seconds
 
R2#sh ip bgp neighbors
BGP neighbor is 1.1.1.1,  remote AS 65001, internal link
  BGP version 4, remote router ID 2.2.2.2
  BGP state = Established, up for 00:15:15  àIBGP邻居已建立
 
 
BGP neighbor is 5.5.5.5,  remote AS 65002, external link
  BGP version 4, remote router ID 6.6.6.6
  BGP state = Established, up for 00:19:25  àEBGP邻居已建立
 
R3#sh ip bgp neighbors
BGP neighbor is 3.3.3.3,  remote AS 65001, external link
  BGP version 4, remote router ID 4.4.4.4
  BGP state = Established, up for 00:22:59  àEBGP邻居已建立
 
 
步骤七:查看bgp转发表
 
R1#sh ip bgp
BGP table version is 5, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
 
   Network          Next Hop        Metric LocPrf Weight Path
*> 2.2.2.0/24       0.0.0.0                 0         32768 i
*>i4.4.4.0/24       3.3.3.3                 0    100      0 i
*>i6.6.6.0/24       3.3.3.3                 0    100      0 65002 i
* i10.1.1.0/24      3.3.3.3                 0    100      0 i
*>                0.0.0.0                0         32768 i
 
R2#sh ip bgp
BGP table version is 5, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
 
   Network          Next Hop         Metric LocPrf Weight Path
*>i2.2.2.0/24       1.1.1.1                  0   100      0 i
*> 4.4.4.0/24       0.0.0.0                  0         32768 i
*> 6.6.6.0/24       5.5.5.5                  0             0 65002 i
* i10.1.1.0/24      1.1.1.1                  0    100      0 i
*>               0.0.0.0                  0         32768 i
 
R3#sh ip bgp
BGP table version is 5, local router ID is 6.6.6.6
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
 
   Network          Next Hop         Metric LocPrf Weight Path
*> 2.2.2.0/24       3.3.3.3                                0 65001 i
*> 4.4.4.0/24       3.3.3.3                  0             0 65001 i
*> 6.6.6.0/24       0.0.0.0                  0         32768 i
*> 10.1.1.0/24      3.3.3.3                  0             0 65001 i
 
 
步骤八:用ping命令测试连通性或用扩展ping命令
 
R1#ping  6.6.6.6
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 60/60/64 ms
 
 
R1#ping 4.4.4.4
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/32/32 ms
 
R2#ping 2.2.2.2
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/32/32 ms
 
R3#ping 2.2.2.2
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 60/60/60 ms
 
 
r3#ping 4.4.4.4
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/32/32 ms
 
 
步骤九:查看配置
 
R1#sh run
hostname R1
!
interface Loopback0
 ip address 1.1.1.1 255.255.255.0
!
interface Loopback1
 ip address 2.2.2.2 255.255.255.0
!
interface Serial0
 ip address 10.1.1.1 255.255.255.0
 clockrate 64000
!
router eigrp 100
 network 1.1.1.0 0.0.0.255
 network 10.1.1.0 0.0.0.255
 no auto-summary
!
router bgp 65001
 no synchronization
network 2.2.2.0 mask 255.255.255.0
 network 10.1.1.0 mask 255.255.255.0
 neighbor 3.3.3.3 remote-as 65001
 neighbor 3.3.3.3 update-source Loopback0
 no auto-summary
!
end
 
 
R2#sh run
hostname R2
!
interface Loopback0
 ip address 3.3.3.3 255.255.255.0
!
interface Loopback1
 ip address 4.4.4.4 255.255.255.0
!
interface Serial0
 ip address 20.1.1.1 255.255.255.0
!
interface Serial1
 ip address 10.1.1.2 255.255.255.0
!
router eigrp 100
 network 3.3.3.0 0.0.0.255
 network 10.1.1.0 0.0.0.255
 no auto-summary
!
router bgp 65001
 no synchronization
network 4.4.4.0 mask 255.255.255.0
 network 10.1.1.0 mask 255.255.255.0
 neighbor 1.1.1.1 remote-as 65001
 neighbor 1.1.1.1 update-source Loopback0
 neighbor 1.1.1.1 next-hop-self
 neighbor 5.5.5.5 remote-as 65002
 neighbor 5.5.5.5 ebgp-multihop 255
 neighbor 5.5.5.5 update-source Loopback0
 no auto-summary
!
ip route 5.5.5.0 255.255.255.0 20.1.1.2
end
 
R3#sh run
Hostname R3
!
interface Loopback0
 ip address 5.5.5.5 255.255.255.0
!
interface Loopback1
 ip address 6.6.6.6 255.255.255.0
!
interface Serial1
 ip address 20.1.1.2 255.255.255.0
 clockrate 64000
!
router bgp 65002
network 6.6.6.0 mask 255.255.255.0
 neighbor 3.3.3.3 remote-as 65001
 neighbor 3.3.3.3 ebgp-multihop 255
 neighbor 3.3.3.3 update-source Loopback0
 no auto-summary
!
ip route 3.3.3.0 255.255.255.0 20.1.1.1
end