您的位置:首页 > 其它

【实验9.11.1】 配置BGP的缺省路由【IEEEnjoy.L.ZH】

2007-04-09 22:39 766 查看
实验9.11.1 配置BGP的缺省路由
一、实验拓扑:



二、实验目的:
作为世界级顶级IT网络培训公司的ITAA在招标之后决定接入两家ISP,分别为ISP1和ISP2,由这两家ISP为ITAA提供非洲的互联网内容接入,而ITAA为其提供亚太地区的接入,本案例中,只考虑如何保证ITAA能够不间断,有保障的接入非洲互联网。
方案:主要流量通过ISP1出去,ISP2做备用(无间断备用,不惜一切代价保证ITAA每分每秒的不间断接入)。
目录:
-基本链路配置
-安全配置:限制ISP1 和 ISP 2互通
-尝试方案:配置两条静态路由;
-最终方案:配置默认路由,再配一条静态路由;
-结论
-一些未解疑问
三、实验开始:
基本链路配置:

ISP 1

interface Loopback0
ip address 1.1.1.1 255.255.255.0
!
interface Serial1/0
ip address 10.0.0.1 255.255.255.0
serial restart-delay 0
!
!
router bgp 10
no synchronization
bgp log-neighbor-changes
network 1.1.1.0 mask 255.255.255.0
neighbor 10.0.0.2 remote-as 20
no auto-summary
!
ISP2

interface Loopback0
ip address 3.3.3.3 255.255.255.0
!
interface Serial1/1
ip address 20.0.0.3 255.255.255.0
serial restart-delay 0
!
router bgp 30
no synchronization
bgp log-neighbor-changes
network 3.3.3.0 mask 255.255.255.0
neighbor 20.0.0.2 remote-as 20
no auto-summary
ITAA

interface Loopback0
ip address 30.0.0.2 255.255.255.0
!
interface Loopback1
ip address 30.0.1.2 255.255.255.0
!
interface Serial1/0
ip address 20.0.0.2 255.255.255.0
serial restart-delay 0
!
interface Serial1/1
ip address 10.0.0.2 255.255.255.0
serial restart-delay 0
!
router bgp 20
no synchronization
bgp log-neighbor-changes
network 30.0.0.0 mask 255.255.255.0
network 30.0.1.0 mask 255.255.255.0
neighbor 10.0.0.1 remote-as 10
neighbor 20.0.0.3 remote-as 30
no auto-summary
!
安全配置:限制ISP1 和 ISP 2互通
在ITAA上配置访问控制链表,并在BGP中使用nei x.x.x.x distribute-list X 命令控制路由的发布,以防止ISP1和ISP2互通。配置如下:

ITAA#conf t
ITAA(config)# access-list 1 per 30.0.0.0 0.0.1.255
ITAA(config)# router bgp 20
ITAA(config-route)# nei 20.0.0.3 distribute-list 1 out
ITAA(config-route)# nei 10.0.0.1 distribute-list 1 out
在ITAA上clear ip bgp *重新建立BGP连接之后,可以在ISP1 和 ISP2 上分别查看bgp信息:

ISP2#sh ip bgp
BGP table version is 22, local router ID is 3.3.3.3
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
*> 3.3.3.0/24 0.0.0.0 0 32768 i
*> 30.0.0.0/24 20.0.0.2 0 0 20 i
*> 30.0.1.0/24 20.0.0.2 0 0 20 i
就无法看到ISP1的路由信息了。
尝试方案:配置两条静态路由

ITAA(config)#ip route 0.0.0.0 0.0.0.0 10.0.0.1 210
ITAA(config)#ip route 0.0.0.0 0.0.0.0 20.0.0.2 220
ITAA#sh ip rou
Gateway of last resort is 10.0.0.1 to network 0.0.0.0

B 210.210.210.0/24 [20/0] via 10.0.0.1, 00:56:26
1.0.0.0/24 is subnetted, 1 subnets
B 1.1.1.0 [20/0] via 10.0.0.1, 00:56:26
3.0.0.0/24 is subnetted, 1 subnets
B 3.3.3.0 [20/0] via 20.0.0.3, 01:25:08
20.0.0.0/24 is subnetted, 1 subnets
C 20.0.0.0 is directly connected, Serial1/0
10.0.0.0/24 is subnetted, 1 subnets
C 10.0.0.0 is directly connected, Serial1/1
30.0.0.0/24 is subnetted, 2 subnets
C 30.0.0.0 is directly connected, Loopback0
C 30.0.1.0 is directly connected, Loopback1
S* 0.0.0.0/0 [210/0] via 10.0.0.1

这么看起来,貌似没有什么问题,最后的resort也成功的设置成为10.0.0.1,但是,如果这条链路断开,会不会马上切换到另一条静态路由呢?我们来看一下:
首先,在ISP1上shutdown掉s1/0端口,在ITAA上观看现象很明显:

ITAA#sh ip rou
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 10.0.0.1 to network 0.0.0.0

B 210.210.210.0/24 [20/0] via 10.0.0.1, 01:00:11
1.0.0.0/24 is subnetted, 1 subnets
B 1.1.1.0 [20/0] via 10.0.0.1, 01:00:11
3.0.0.0/24 is subnetted, 1 subnets
B 3.3.3.0 [20/0] via 20.0.0.3, 01:28:53
20.0.0.0/24 is subnetted, 1 subnets
C 20.0.0.0 is directly connected, Serial1/0
10.0.0.0/24 is subnetted, 1 subnets
C 10.0.0.0 is directly connected, Serial1/1
30.0.0.0/24 is subnetted, 2 subnets
C 30.0.0.0 is directly connected, Loopback0
C 30.0.1.0 is directly connected, Loopback1
S* 0.0.0.0/0 [210/0] via 10.0.0.1 …………………………………….
ITAA#p 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 0 percent (0/5)………………………………………………
ITAA#
*Apr 4 12:15:24.871: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/1, changed state to down
*Apr 4 12:15:24.883: %BGP-5-ADJCHANGE: neighbor 10.0.0.1 Down Interface flap
ITAA#sh ip rou
Gateway of last resort is 20.0.0.3 to network 0.0.0.0

3.0.0.0/24 is subnetted, 1 subnets
B 3.3.3.0 [20/0] via 20.0.0.3, 01:34:39
20.0.0.0/24 is subnetted, 1 subnets
C 20.0.0.0 is directly connected, Serial1/0
30.0.0.0/24 is subnetted, 2 subnets
C 30.0.0.0 is directly connected, Loopback0
C 30.0.1.0 is directly connected, Loopback1
S* 0.0.0.0/0 [220/0] via 20.0.0.3…………………………………………..
上面的表格是在我们shutdown ISP1对应端口后的现象,我们很明显的看到,三个序号的顺序很不正常,首先路由表中有通往1.1.1.1的路由,但却又无法ping通,然后才收到BGP链路down掉的信息,其次才是路由表的更新,这样的做法会导致一定时间ITAA无法访问非洲互联网,情况极其不能接受!怎么办?改!
最终方案:配置默认路由,再配一条静态路由
我们只好采用默认路由方式一试!
首先,我们在ISP1中再起一个环回口,IP为210.210.210.1,并在BGP通告出来。

ITAA#sh ip bgp
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.0/24 10.0.0.1 0 0 10 i
*> 3.3.3.0/24 20.0.0.3 0 0 30 i
*> 30.0.0.0/24 0.0.0.0 0 32768 i
*> 30.0.1.0/24 0.0.0.0 0 32768 i
*> 210.210.210.0 10.0.0.1 0 0 10 i
在ITAA中配置:ip default-network 210.210.210.0,查看路由表:

ITAA#sh ip rou
Gateway of last resort is 10.0.0.1 to network 210.210.210.0

B* 210.210.210.0/24 [20/0] via 10.0.0.1, 00:01:08
1.0.0.0/24 is subnetted, 1 subnets
B 1.1.1.0 [20/0] via 10.0.0.1, 00:01:08
3.0.0.0/24 is subnetted, 1 subnets
B 3.3.3.0 [20/0] via 20.0.0.3, 01:39:21
20.0.0.0/24 is subnetted, 1 subnets
C 20.0.0.0 is directly connected, Serial1/0
10.0.0.0/24 is subnetted, 1 subnets
C 10.0.0.0 is directly connected, Serial1/1
30.0.0.0/24 is subnetted, 2 subnets
C 30.0.0.0 is directly connected, Loopback0
C 30.0.1.0 is directly connected, Loopback1
S* 0.0.0.0/0 [220/0] via 20.0.0.3
OK,到此我们看到了一个比较不错的结果,路由表里面同时存在两条”*”路由,可以实现无间断的路由,我们来验证一下,在ISP1上关闭接口,当我们迅速切回到ITAA上查看路由信息的时候,依然没有及时更新路由,但是没关系,S* 0.0.0.0/0 [220/0] via 20.0.0.3,这条路由不是吃素的,可以迅速为我们接通非洲互联网!
结论:
想要无间断的路由,首先我们不能强迫BGP的反应时间,我们没有办法,所以我们就要想办法在路由表中安置两条路由,那么我们的方案就是使用ip default-net 命令!
特别注意:在BGP中,network命令必须是路由条目里面的,包括后面的掩码都非常重要,这点可能大家都知道,但往往容易出错,导致BGP中发布路由不成功;
一些未解疑问:

在设置default-network的时候也得注意掩码,应该是主类地址,但有个疑问,当我设置为5.0.0.0这样的A类地址的时候,在sh ip rou的时候, 显示Gateway of last resort is not set.但在路由条目中5.0.0.0/24这条前面会有一个"*",表示是制定的默认路由,而设置为类似210.210.210.0这样的C类地址的时候就可以显示
Gateway of last resort is 10.0.0.1 to network 210.210.210.0,下面对应的路由条目也有"*";
为什么?
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: