next hop c语言实现,BGP的NEXT-HOP-SELF试验

BGP的NEXT-HO-SELF试验

拓扑:

bcdddb893fdabdfc8f799fb6955c3877.png

R1与R2建立EBGP对等体,R2与R1建立EBGP对等体,R3与R2建立IBGP对等体与R4建立EBGP对等体, R4与R3是EBGP对等体

R1通告1.1.10/24网络给EBGP对等体R2,R2通告给R3,R3会再转发给R4么???

答案是不会的,因为,当R3学到这一路由时,1.1.1.0/24这一网络的下一跳是10.1.1.1而R3是不可到达的,此时可在R2上做next-hop-self来解决这一问题

R1配置

Router>EN

Router#conf t

R1(config)#int s1/1

R1(config-if)#ip add 10.1.1.1 255.255.255.0

R1(config-if)#no sh

R1(config-if)#int lo 0

R1(config-if)#ip add 1.1.1.1 255.255.255.0

R1(config-if)#no sh

R1(config-if)#exi

R1(config)#router bgp 100

R1(config-router)#net 1.1.1.0 mask 255.255.255.0

R1(config-router)#nei 10.1.1.2 remote 200

R2配置:

Router>en

Router#conf t

R2(config)#int s1/0

R2(config-if)#ip add 10.1.1.2 255.255.255.0

R2(config-if)#no sh

R2(config-if)#int s1/1

R2(config-if)#ip add 10.2.2.1 255.255.255.0

R2(config-if)#no sh

R2(config-if)#exi

R2(config)#router bgp 200

R2(config-router)#nei 10.1.1.1 remote 100

R2(config-router)#nei 10.2.2.2 remote 200

R3配置:

Router>en

Router#conf t

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

Router(config)#host R3

R3(config)#int s1/0

R3(config-if)#ip add 10.2.2.2 255.255.255.0

R3(config-if)#no sh

R3(config-if)#int s1/1

R3(config-if)#ip add 10.3.3.1 255.255.255.0

R3(config-if)#no sh

R3(config-if)#exi

R3(config)#router bgp 200

R3(config-router)#nei 10.2.2.1 remote 200

R3(config-router)#nei 10.3.3.2 remote 300

R4配置:

Router>en

Router#conf t

R4(config)#int s1/0

R4(config-if)#ip add 10.3.3.2 255.255.255.0

R4(config-if)#no sh

R4(config-if)#exi

R4(config)#router bgp 300

R4(config-router)#nei 10.3.3.1 remote 200

查看R3 R4的BGP转发表:

R3#sh ip bgp

BGP table version is 1, local router ID is 10.3.3.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

NetworkNext HopMetric LocPrf Weight Path

* i1.1.1.0/2410.1.1.101000 100

(标注为不是最优的)

就不会再转发这一路由,只有同时是*>才转发

R4#sh ip bgp

R4#sh 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

10.0.0.0/24 is subnetted, 1 subnets

C10.3.3.0 is directly connected, Serial1/0

R4没学到1.1.1.0/24!!!!!!55555555

在R2上做NEXT-HO-SELF

R2(config)#router bgp 200

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

再查看R4的转发表和路由表:

R4#sh ip bgp

BGP table version is 2, local router ID is 10.3.3.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

NetworkNext HopMetric LocPrf Weight Path

*> 1.1.1.0/2410.3.3.10 200

R4#sh 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

B1.1.1.0 [20/0] via 10.3.3.1, 00:01:32(学的了咯!!!o(∩_∩)o…)

10.0.0.0/24 is subnetted, 1 subnets

C10.3.3.0 is directly connected, Serial1/0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值