实验拓扑:
BGP-1_职场
实验目的:
1.       熟悉BGP的基本配置
2.       控制BGP邻居的下一跳指向
3.       EBGPIBGP的基本配置
 
实验步骤:
1.       各路由器接口的IP地址的配置:
a)         R1的配置:
Router#configure terminal
R1(config)#interface s1/2
R1(config-if)#ip address 192.168.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config)#interface loopback 0
R1(config-if)#ip address 1.1.1.1 255.255.255.0
R1(config)#interface loopback 10
R1(config-if)#ip address 10.1.1.1 255.255.255.0
 
b)        R2的配置:
R2(config)#interface s1/3
R2(config-if)#ip address 192.168.1.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#interface s1/2
R2(config-if)#ip address 192.168.2.1 255.255.255.0
R2(config-if)#no shutdown
R2(config)#interface loopback 0
R2(config-if)#ip address 2.2.2.2 255.255.255.0
c)        R3的配置:
R3(config)#interface s1/3
R3(config-if)#ip address 192.168.2.2 255.255.255.0
R3(config-if)#no shutdown
R3(config)#interface loopback 0
R3(config-if)#ip address 3.3.3.3 255.255.255.0
2.       IGP路由配置为EIGRP,做到全网全通:
a)         R1的配置:
R1(config)#router eigrp 100
R1(config-router)#no auto-summary
R1(config-router)#network 192.168.1.0 0.0.0.255
R1(config-router)#network 1.1.1.0 0.0.0.255   
R1(config-router)#network 10.1.1.0 0.0.0.255
b)        R2的配置:
R2(config)#router eigrp 100
R2config-router)#no auto-summary
R2(config-router)#network 192.168.1.0 0.0.0.255
R2(config-router)#network 192.168.2.0 0.0.0.255
R2(config-router)#network 2.2.2.0 0.0.0.255   
c)        R3的配置:
R3(config)#router eigrp 100
R3(config-router)#no auto-summary
R3(config-router)#network 192.168.2.0 0.0.0.255
R3(config-router)#network 3.3.3.0 0.0.0.255
配置完成后在R3上分别ping 10.1.1.11.1.1.1测试连通性。
3.       R1R3配置为AS1R2配置为AS 2
a)         R1的配置:
R1(config)#router bgp 1
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#no auto-summary
R1(config-router)#no synchronization
R1(config-router)#neighbor 3.3.3.3 remote-as 1
R1(config-router)#neighbor 3.3.3.3 update-source loopback 0
R1(config-router)#network 10.1.1.0 mask 255.255.255.0
 
b)        R3的配置:
R3(config)#router bgp 1
R3(config-router)#bgp router-id 3.3.3.3
R3(config-router)#no auto-summary
R3(config-router)#no synchronization
R3(config-router)#neighbor 1.1.1.1 remote-as 1
R3(config-router)#neighbor 1.1.1.1 update-source loopback 0
R3(config-router)#neighbor 2.2.2.2 remote-as 2
R3(config-router)#neighbor 2.2.2.2 ebgp-multihop
R3(config-router)#neighbor 2.2.2.2 update-source loopback 0
 
c)        R2的配置:
R2(config)#router bgp 2
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#no auto-summary
R2(config-router)#no synchronization
R2(config-router)#neighbor 3.3.3.3 remote-as 1
R2(config-router)#neighbor 3.3.3.3 update-source loopback 0
R2(config-router)#neighbor 3.3.3.3 ebgp-multihop
4.       这样配置完成后在R3ping 10.1.1.1是不通的,如下:
R3#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
 
     1.0.0.0/24 is subnetted, 1 subnets
D       1.1.1.0 [90/2809856] via 192.168.2.1, 00:16:01, Serial1/3
     2.0.0.0/24 is subnetted, 1 subnets
D       2.2.2.0 [90/2297856] via 192.168.2.1, 00:18:06, Serial1/3
     3.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C       3.3.3.0/24 is directly connected, Loopback0
D       3.0.0.0/8 is a summary, 00:16:01, Null0
     10.0.0.0/24 is subnetted, 1 subnets
B       10.1.1.0 [200/0] via 1.1.1.1, 00:04:10
D    192.168.1.0/24 [90/2681856] via 192.168.2.1, 00:18:06, Serial1/3
C    192.168.2.0/24 is directly connected, Serial1/3
R3#ping 10.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
 
R3#traceroute 10.1.1.1
Type escape sequence to abort.
Tracing the route to 10.1.1.1
  1 192.168.2.1 80 msec 192 msec 72 msec
  2 192.168.2.2 240 msec 168 msec 488 msec
  3 192.168.2.1 216 msec 192 msec 168 msec
  4 192.168.2.2 312 msec 264 msec 288 msec
  5 192.168.2.1 496 msec 264 msec 360 msec
  6 192.168.2.2 432 msec 368 msec 504 msec
  7 192.168.2.1 360 msec 312 msec 424 msec
  8 192.168.2.2 404 msec 592 msec 312 msec
  9 192.168.2.1 308 msec 576 msec 552 msec
 10 192.168.2.2 712 msec 528 msec 536 msec
 11 192.168.2.1 452 msec 380 msec 480 msec
 12 192.168.2.2 528 msec 648 msec 456 msec
 13 192.168.2.1 816 msec 736 msec 456 msec
 14 192.168.2.2 552 msec 816 msec 768 msec
 15 192.168.2.1 784 msec 604 msec 672 msec
 16 192.168.2.2 912 msec 744 msec 864 msec
 17 192.168.2.1 800 msec 704 msec 748 msec
 18 192.168.2.2 972 msec 840 msec 648 msec
 19 192.168.2.1 936 msec 736 msec 720 msec
 20 192.168.2.2 792 msec 768 msec 992 msec
 21 192.168.2.1 824 msec 864 msec 936 msec
 22 192.168.2.2 1072 msec 1224 msec 1120 msec
 23 192.168.2.1 1000 msec 1048 msec 1104 msec
 24 192.168.2.2 1368 msec 1104 msec 1560 msec
 25 192.168.2.1 1080 msec 1200 msec 1248 msec
 26 192.168.2.2 1912 msec 1296 msec 944 msec
 27 192.168.2.1 1260 msec 1280 msec 1144 msec
 28 192.168.2.2 1288 msec 1220 msec 1232 msec
 29 192.168.2.1 1336 msec 1144 msec 1568 msec
 30 192.168.2.2 1296 msec 1368 msec 1416 msec
       R3上做设置:R3(config-router)#neighbor 2.2.2.2 next-hop-unchanged
              然后再测试:
                     R3#ping 10.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 96/170/216 ms
       R3#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
 
     1.0.0.0/24 is subnetted, 1 subnets
D       1.1.1.0 [90/2809856] via 192.168.2.1, 00:23:46, Serial1/3
     2.0.0.0/24 is subnetted, 1 subnets
D       2.2.2.0 [90/2297856] via 192.168.2.1, 00:25:51, Serial1/3
     3.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C       3.3.3.0/24 is directly connected, Loopback0
D       3.0.0.0/8 is a summary, 00:23:46, Null0
     10.0.0.0/24 is subnetted, 1 subnets
B       10.1.1.0 [200/0] via 1.1.1.1, 00:11:55
D    192.168.1.0/24 [90/2681856] via 192.168.2.1, 00:25:51, Serial1/3
C    192.168.2.0/24 is directly connected, Serial1/3
R2#show 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
*> 10.1.1.0/24      1.1.1.1                                0 1 i
 
实验总结:当R3在设置BGP邻居R2的时候要设点R2next-hop指向保持不变,即指向1.1.1.1,不然ping 10.1.1.1的时候包会在R3R2之间循环。