BGP选路规则实验
- 格式:docx
- 大小:49.27 KB
- 文档页数:16
bgp口字形选路口字形BGP 选路配置案例1 组网拓扑:2 组网搭建:利用H3CSE 虚拟实验室拓扑来搭建共用路由器4台。
3实验目的RT9 发布的9.9.9.9 的BGP 路由沿着一条路径转发到让RT10 10.10.10.104 组网配置脚本:RT1:di cur#version 5.20, Alpha 1011#sysname rt1#password-control login-attempt 3 exceed lock-time 120#undo voice vlan mac-address 00e0-bb00-0000#ipsec cpu-backup enable#undo cryptoengine enable#firewall enable#domain default enable system#vlan 1#domain systemaccess-limit disablestate activeidle-cut disableself-service-url disable#acl number 2000rule 0 deny source 9.9.9.9 0#interface Ethernet0/1/0port link-mode route#interface Serial0/2/0link-protocol pppip address 10.1.12.1 255.255.255.0 # interface Serial0/2/1link-protocol pppip address 10.1.100.1 255.255.255.0 # interface Serial0/2/2link-protocol ppp#interface Serial0/2/3link-protocol pppip address 10.1.19.1 255.255.255.0 # interface NULL0#interface Ethernet0/4/0port link-mode bridge#interface Ethernet0/4/1port link-mode bridge#interface Ethernet0/4/2port link-mode bridge#interface Ethernet0/4/3port link-mode bridge#interface Ethernet0/4/4port link-mode bridge#interface Ethernet0/4/5port link-mode bridge#interface Ethernet0/4/6port link-mode bridge#interface Ethernet0/4/7port link-mode bridge#bgp 200default local-preference 200 undo synchronizationpeer 10.1.19.9 as-number 100 group 200 internalpeer 10.1.100.10 group 200 #load xml-configuration#user-interface con 0user-interface vty 0 4#returnRT9dis cur#version 5.20, Alpha 1011#sysname rt2009#password-control login-attempt 3 exceed lock-time 120 # undo voice vlan mac-address 00e0-bb00-0000#ipsec cpu-backup enable#undo cryptoengine enable#domain default enable system#vlan 1#domain systemaccess-limit disablestate activeidle-cut disableself-service-url disable#interface Ethernet0/1/0port link-mode route#interface Serial0/2/0link-protocol pppip address 10.1.19.9 255.255.255.0 # interface Serial0/2/1link-protocol pppip address 10.1.89.9 255.255.255.0 # interface NULL0#interface LoopBack0ip address 9.9.9.9 255.255.255.255 # interface Ethernet0/4/0port link-mode bridge#interface Ethernet0/4/1port link-mode bridge#interface Ethernet0/4/2port link-mode bridge#interface Ethernet0/4/3port link-mode bridge#interface Ethernet0/4/4port link-mode bridge#interface Ethernet0/4/5port link-mode bridge#interface Ethernet0/4/6port link-mode bridge#interface Ethernet0/4/7port link-mode bridge#bgp 100undo synchronizationpeer 10.1.89.8 as-number 200peer 10.1.19.1 as-number 200#ip community-list 1 permit 11#load xml-configuration#user-interface con 0user-interface vty 0 4#returnRT8di cur#version 5.20, Alpha 1011#sysname rt8#password-control login-attempt 3 exceed lock-time 120 # undo voice vlan mac-address 00e0-bb00-0000#ipsec cpu-backup enable#undo cryptoengine enable#domain default enable system#vlan 1#domain systemaccess-limit disablestate activeidle-cut disableself-service-url disable#interface Ethernet0/1/0port link-mode route#interface Serial0/2/0link-protocol ppp#interface Serial0/2/1link-protocol ppp#interface Serial0/2/2link-protocol ppp#interface Serial0/2/3link-protocol pppip address 10.1.89.8 255.255.255.0 # interface NULL0#interface Ethernet0/4/0port link-mode bridge#interface Ethernet0/4/1port link-mode bridge#interface Ethernet0/4/2port link-mode bridge#interface Ethernet0/4/3port link-mode bridge#interface Ethernet0/4/4port link-mode bridge#interface Ethernet0/4/5port link-mode bridge#interface Ethernet0/4/6port link-mode bridge#interface Ethernet0/4/7port link-mode bridge#bgp 200undo synchronizationpeer 10.1.100.10 as-number 200 peer 10.1.89.9 as-number 100 undo peer 10.1.100.10 enable group 200 internal peer 10.1.80.10 group 200peer 10.1.80.10 next-hop-local#load xml-configuration#user-interface con 0user-interface vty 0 4#returnRT10di cur#version 5.20, Alpha 1011#sysname rt10#password-control login-attempt 3 exceed lock-time 120 # undo voice vlan mac-address 00e0-bb00-0000#ipsec cpu-backup enable#undo cryptoengine enable#domain default enable system#gvrp#vlan 1#domain systemaccess-limit disablestate activeidle-cut disableself-service-url disable#interface Serial0/2/0link-protocol ppp#interface Serial0/2/1link-protocol pppip address 10.1.100.10 255.255.255.0 #interface Serial0/2/2link-protocol ppp#interface Serial0/2/3link-protocol ppp#interface Serial0/2/4link-protocol ppp#interface Serial0/2/5link-protocol ppp#interface Serial0/2/6link-protocol ppp#interface Serial0/2/7link-protocol ppp#interface Serial0/2/8link-protocol pppip address 10.1.80.10 255.255.255.0#interface NULL0#interface LoopBack0ip address 10.10.10.10 255.255.255.255 # interface Ethernet0/4/0port link-mode bridge#interface Ethernet0/4/1port link-mode bridge#interface Ethernet0/4/2port link-mode bridge#interface Ethernet0/4/3port link-mode bridge#interface Ethernet0/4/4port link-mode bridge#interface Ethernet0/4/5port link-mode bridge#interface Ethernet0/4/6port link-mode bridge#interface Ethernet0/4/7port link-mode bridge#bgp 200network 10.10.10.10 255.255.255.255 undo synchronization group 200 internalpeer 10.1.100.1 group 200 peer 10.1.80.8 group 200 #ip as-path 1 deny 1#load xml-configuration #user-interface con 0user-interface vty 0 4#return。
BGP综合实验基本配置略。
注意的是我的RT1上的源地址是12.12.12.1所有ipv6地址是2002:c0c:c01:2::1(你自己的是什么就写什么)同理RT5上我用的源地址是5.5.5.5,ipv6地址是2002:505:505:2:1BGP配置Ospf配置略。
加入验证增加安全注意把12.12.12.0网段发布下不然IPV6隧道路由你还得引入什么的6TO4隧道RT1(注意先开启ipv6功能)ipv6 route-static 2002:: 16 Tunnel 0两边加入静态路由可以看到没有问题选路问题选路有多种方法我这里修改的通过BGP修改下一跳,别的方法我也迷糊,- -!首先我们看RT2的路由表,我只是截取了部分我们想看的太多我们先做RT1到RT5的路由选路,原理是做一个route-policy的过滤器,在第一个节点匹配10.0.0.1和11.0.0.1这个网段的或者这个IP,动作是修改下一跳为3.3.3.3(这个3.3.3.3可以让你断一条链路的情况下也能互通)我这个是为了方便在这RT5的一边做的同样匹配10.0.1.1和11.0.1.1这个,动作是修改下一跳为4.4.4.4应用到import和export两个方向上还需要注意的是11.0.0.1和11.0.1.1这两条路由产生了黑洞,黑洞在RT3和RT4上我没还需要在RT3和RT4上加入静态路由解决黑洞[RT3]ip route-static 11.0.0.0 24 5.5.5.5[RT4]ip route-static 11.0.1.0 24 5.5.5.5这样我们再看路由表RT2上RT5上OK了命令简单想费劲RT1上测试RT5上来回路径一致。
BGP选路规则BGP选路规则一、下一跳可达BGP选路规则一共13条,第一条必须是下一跳可达,如果下一跳不可达后面的12条全部不生效。
BGP选路规则二、Preferred Value(优选值)选择条件1、默认值为02、不会传递,只会在本路由器生效3、优选值越大越优先============================================================================= Total Number of Routes: 4Network NextHop MED LocPrf PrefVa l Path/Ogn*>i 100.1.1.1/32 10.1.5.5 100 0 200 100i* i 10.1.6.6 100 0200 100i*>i 100.1.2.1/32 10.1.5.5 100 0 200 100i* i 10.1.6.6 100 0200 100i============================================================================= 实验拓扑图拓扑图描述:R7上分别从R5和R6上学习到100.1.1.1和100.1.2.12条路由,默认BGP优选R5(10.1.5.5)作为去往100.1.1.1和100.1.2.1网络的下一跳,通过路由策略修改BGP首选值让R7将去往10.1.1.1的路由优选R5,10.1.2.1的路由优选R6。
============================================================================= R7配置acl number 2000 \\创建ACL匹配感兴趣流量rule 1 permit source 100.1.1.1 0acl number 2001rule 1 permit source 100.1.2.1 0#route-policy PrefVal permit node 10 \\创建名称为PrefVal的路由策略,动作是允许通过if-match acl 2000\\如果匹配ACL2000apply preferred-value 100\\将BGP首选值调整为100#route-policy PrefVal permit node 1000 \\创建名称为PrefVal的路由策略,不匹配的路由不做修改#route-policy PrefVal-1 permit node 10 \\创建名称为PrefVal-1的路由策略,动作是允许通过if-match acl 2001 \\如果匹配ACL2001apply preferred-value 100\\将BGP首选值调整为100#route-policy PrefVal-1 permit node 1000 \\创建名称为PrefVal-1的路由策略,不匹配的路由不做修bgp 300router-id 7.7.7.7peer 10.1.5.5 as-number 300peer 10.1.5.5 connect-interface LoopBack0peer 10.1.6.6 as-number 300peer 10.1.6.6 connect-interface LoopBack0#ipv4-family unicastundo synchronizationpeer 10.1.5.5 enablepeer 10.1.5.5 route-policy PrefVal import\\在R7至R5的BGP对等体的入方向上应用路由策略PrefValpeer 10.1.6.6 enablepeer 10.1.6.6 route-policy PrefVal-1 import\\在R7至R6的BGP对等体的入方向上应用路由策略PrefVal-1============================================================================= 验证配置Total Number of Routes: 4Network NextHop MED LocPrf PrefVal Path/Ogn*>i 100.1.1.1/32 10.1.5.5 100 100 200 100i* i 10.1.6.6 100 0 200 100i*>i 100.1.2.1/32 10.1.6.6 100 100 200 100i* i 10.1.5.5 100 0 200 100iBGP选路规则三、Local-Preference(本地优先级)选择条件1、默认值为100(越大越优先)2、只在本AS中传递3、local-preference值一定是上端路由器传过来时没有才会在本路由器赋予(上端路由器是EBGP邻居时传送路由时不会携带local-preference值)4、全局配置本地优先级[Router-BGP]#default local-preference [本地优先级值]============================================================================= Total Number of Routes: 4Network NextHop MED LocPrf PrefVal Path/Ogn*>i 100.1.1.1/32 10.1.5.5 100 0 200 100i* i 10.1.6.6 100 0 200 100i*>i 100.1.2.1/32 10.1.5.5 100 0 200 100i* i 10.1.6.6 100 0 200 100i============================================================================= 实验拓扑拓扑图描述:R7上分别从R5和R6上学习到100.1.1.1和100.1.2.12条路由,默认BGP优选R5(10.1.5.5)作为去往100.1.1.1和100.1.2.1网络的下一跳,通过路由策略修改BGP本地优先级让R7将去往10.1.1.1的路由优选R6,10.1.2.1的路由优选R5。
标题:IPA-task packet002:BGP选路原则原文由Ethan于星期五, 01/14/2011 - 00:53 发表于 实验二:BGP选路原则实验目标:调试和观察BGP的选路原则实验TOP:物理拓扑逻辑拓扑R1!hostname R1!no ip domain lookup!interface Loopback0ip address 1.1.1.1 255.255.255.0!interface Loopback10ip address 10.10.10.10 255.255.255.0 ip ospf network point-to-point!interface Ethernet0/0ip address 10.1.1.1 255.255.255.0!interface Serial1/0ip address 12.1.1.1 255.255.255.0 serial restart-delay 0clock rate 64000!interface Serial2/0ip address 13.1.1.1 255.255.255.0 serial restart-delay 0!router ospf 10router-id 1.1.1.1log-adjacency-changesnetwork 10.1.1.0 0.0.0.255 area 0 network 10.10.10.0 0.0.0.255 area 0 network 12.1.1.0 0.0.0.255 area 0 network 13.1.1.0 0.0.0.255 area 0!router bgp 1no synchronizationbgp router-id 1.1.1.1bgp log-neighbor-changesnetwork 1.1.1.0 mask 255.255.255.0 neighbor 10.1.1.4 remote-as 345 neighbor 12.1.1.2 remote-as 2 neighbor 13.1.1.3 remote-as 345no auto-summary!no ip http serverno ip http secure-server!!line con 0exec-timeout 0 0logging synchronousline aux 0line vty 0 4!EndR2view sourceprint?!hostname R2!no ip domain lookup!!interface Loopback0ip address 2.2.2.2 255.255.255.0!interface Loopback10ip address 20.20.20.20 255.255.255.0 ip ospf network point-to-point!interface Ethernet0/0no ip addressshutdown!interface Serial1/0ip address 24.1.1.2 255.255.255.0 serial restart-delay 0clock rate 64000!interface Serial2/0ip address 12.1.1.2 255.255.255.0 serial restart-delay 0!router ospf 10router-id 2.2.2.2log-adjacency-changesnetwork 12.1.1.0 0.0.0.255 area 0 network 20.20.20.0 0.0.0.255 area 0 network 24.1.1.0 0.0.0.255 area 0!router bgp 2no synchronizationbgp router-id 2.2.2.2bgp log-neighbor-changesnetwork 2.2.2.0 mask 255.255.255.0 neighbor 12.1.1.1 remote-as 1 neighbor 24.1.1.4 remote-as 345no auto-summary!ip classlessno ip http serverno ip http secure-server!!!!!line con 0exec-timeout 0 0logging synchronousline aux 0line vty 0 4!EndR3view sourceprint?!hostname R3!no ip domain lookup!!interface Loopback0ip address 3.3.3.3 255.255.255.0!interface Loopback10ip address 30.30.30.30 255.255.255.0 ip ospf network point-to-point!interface Ethernet0/0no ip addressshutdown!interface Serial1/0ip address 13.1.1.3 255.255.255.0 serial restart-delay 0clock rate 64000!interface Serial2/0ip address 35.1.1.3 255.255.255.0 serial restart-delay 0!router ospf 10router-id 3.3.3.3log-adjacency-changesnetwork 13.1.1.0 0.0.0.255 area 0 network 30.30.30.0 0.0.0.255 area 0 network 35.1.1.0 0.0.0.255 area 0 !router bgp 345no synchronizationbgp router-id 3.3.3.3bgp log-neighbor-changes network 3.3.3.0 mask 255.255.255.0 neighbor 13.1.1.1 remote-as 1 neighbor 35.1.1.5 remote-as 345 neighbor 45.1.1.4 remote-as 345no auto-summary!ip classlessno ip http serverno ip http secure-server!!!!!line con 0exec-timeout 0 0logging synchronousline aux 0line vty 0 4!EndR4view sourceprint?!hostname R4!no ip domain lookup!!interface Loopback0ip address 4.4.4.4 255.255.255.0!interface Loopback10ip address 40.40.40.40 255.255.255.0 ip ospf network point-to-point!interface Ethernet0/0ip address 10.1.1.4 255.255.255.0!interface Serial1/0ip address 45.1.1.4 255.255.255.0 serial restart-delay 0clock rate 64000!interface Serial2/0ip address 24.1.1.4 255.255.255.0 serial restart-delay 0!router ospf 10router-id 4.4.4.4log-adjacency-changesnetwork 10.1.1.0 0.0.0.255 area 0 network 24.1.1.0 0.0.0.255 area 0 network 40.40.40.0 0.0.0.255 area 0 network 45.1.1.0 0.0.0.255 area 0!router bgp 345no synchronizationbgp router-id 4.4.4.4bgp log-neighbor-changesnetwork 4.4.4.0 mask 255.255.255.0 neighbor 10.1.1.1 remote-as 1 neighbor 24.1.1.2 remote-as 2neighbor 35.1.1.3 remote-as 345 neighbor 45.1.1.5 remote-as 345no auto-summary!ip classlessno ip http serverno ip http secure-server!!!!!line con 0exec-timeout 0 0logging synchronousline aux 0line vty 0 4!EndR5!hostname R5!no ip domain lookup!!interface Loopback0ip address 5.5.5.5 255.255.255.0!interface Loopback10ip address 50.50.50.50 255.255.255.0 ip ospf network point-to-point!interface Ethernet0/0no ip addressshutdown!interface Serial1/0ip address 35.1.1.5 255.255.255.0 serial restart-delay 0clock rate 64000!interface Serial2/0ip address 45.1.1.5 255.255.255.0serial restart-delay 0!router ospf 10router-id 5.5.5.5log-adjacency-changesnetwork 35.1.1.0 0.0.0.255 area 0network 45.1.1.0 0.0.0.255 area 0network 50.50.50.0 0.0.0.255 area 0!router bgp 345no synchronizationbgp router-id 5.5.5.5bgp log-neighbor-changesnetwork 5.5.5.0 mask 255.255.255.0neighbor 35.1.1.3 remote-as 345neighbor 45.1.1.4 remote-as 345no auto-summary!ip classlessno ip http serverno ip http secure-server!!!!!line con 0exec-timeout 0 0logging synchronousline aux 0line vty 0 4!End(注:路由器接口默认是关闭的,所以应将对应的接口开启)如上配置,已经将R1至R5基本配置完成。
BGP实验手册实验:BGP宣告精确路由和聚合路由实验:实验拓扑为:说明:R1在AS1,R2在AS2 R3在AS 3R1的具体配置如下:interface Loopback0ip address 192.168.192.1 255.255.255.0interface Loopback1ip address 192.168.193.1 255.255.255.0interface Loopback2ip address 192.168.194.1 255.255.255.0interface Loopback3ip address 192.168.195.1 255.255.255.0interface Loopback4ip address 192.168.196.1 255.255.255.0interface Loopback5ip address 192.168.197.1 255.255.255.0interface Loopback6ip address 192.168.198.1 255.255.255.0interface Loopback7ip address 192.168.199.1 255.255.255.0router ospf 1log-adjacency-changesnetwork 192.168.192.0 0.0.0.255 area 0network 192.168.193.0 0.0.0.255 area 0network 192.168.194.0 0.0.0.255 area 0network 192.168.195.0 0.0.0.255 area 0network 192.168.196.0 0.0.0.255 area 0network 192.168.197.0 0.0.0.255 area 0network 192.168.198.0 0.0.0.255 area 0network 192.168.199.0 0.0.0.255 area 0!router bgp 1aggregate-address 192.168.192.0 255.255.248.0 聚合路由redistribute ospf 1 实验采用重分布,但是实际不建议这样。
实验 BGP路由策略及选路控制一实验拓扑图二实验选路需求(1) AS65001去往10.3.0.0/16的主路径走RT5-RT1(2) AS65001去往102.0.0/16 10.4.0.0/16的主路径走RT6-RT2(3) AS65000去往10.5.0.0/16的主路径走RT1-RT5(4) AS65000去往10.6.0.0/16的主路径走RT2-RT6三分析要满足上面的需求可以通过改变BGP路由的属性值进行路径的选择,因此可以通过三种方法,一改变权重,二改变本地优先级,三改MED。
下面用具体实验说明四实验IGP路由配置r1(config#router ospf 1r1(config-router#router-id 10.0.0.1r1(config-router#net 10.0.0.1 0.0.0.0 area 0r1(config-router#net 10.0.1.4 0.0.0.3 area 0r1(config-router#net 10.0.1.12 0.0.0.3 area 0r1(config-router#passive-interface lo 0r1(config-router#redistribute connected subnets metric 1000 metric-type 1 //直连重发布r2(config-router#router-id 10.0.0.2r2(config-router#net 10.0.0.2 0.0.0.0 area 0r2(config-router#net 10.0.1.8 0.0.0.3 area 0r2(config-router#net 10.0.1.14 0.0.0.0 area 0r2(config-router#passive-interface lo 0r2(config-router#redistribute connected subnets metric 1000 metric-type 1 r2(config-router#exitr3(config#router ospf 1r3(config-router#router-id 10.0.0.3r3(config-router#net 10.0.0.3 0.0.0.0 area 0r3(config-router#net 10.0.1.5 0.0.0.0 area 0r3(config-router#net 10.0.1.0 0.0.0.3 area 0r3(config-router#passive-interface lo 0r3(config-router#net 10.3.3.0 0.0.0.255 area 0r3(config-router#passive-interface e3/0r3(config-router#exitr4(config#router ospf 1r4(config-router#router-id 10.0.0.4r4(config-router#net 10.0.0.4 0.0.0.0 area 0r4(config-router#net 10.0.1.2 0.0.0.0 area 0r4(config-router#net 10.0.1.9 0.0.0.0 area 0r4(config-router#passive-interface lo 0r4(config-router#net 10.4.4.0 0.0.0.255 area 0r4(config-router#net 10.2.2.0 0.0.0.255 area 0r4(config-router#passive-interface e3/0r4(config-router#passive-interface e3/1r5(config#router ospf 1r5(config-router#router-id 10.5.0.1r5(config-router#net 10.5.0.1 0.0.0.0 area 0r5(config-router#net 10.5.1.0 0.0.0.3 area 0r5(config-router#net 10.0.15.0 0.0.0.3 area 0r5(config-router#passive-interface s0/0 //network+passive发布边界网段r5(config-router#passive-interface lo 0r5(config-router#exitr6(config#router ospf 1r6(config-router#router-id 10.6.0.1r6(config-router#net 10.6.0.1 0.0.0.0 area 0r6(config-router#network 10.5.1.2 0.0.0.0 area 0r6(config-router#net 10.6.6.0 0.0.0.255 area 0r6(config-router#passive-interface lo 0r6(config-router#net 10.0.26.0 0.0.0.3 area 0r6(config-router#passive-interface s0/0r6(config-router#passive-interface e3/0r6(config-router#endBGP邻居配置r1(config#router bgp 65000r1(config-router#no synchronizationr1(config-router#no aur1(config-router#nei 10.0.15.2 remote-as 65001r1(config-router#nei 10.0.0.3 remote-as 65000r1(config-router#nei 10.0.0.3 update-source lo 0r1(config-router#nei 10.0.0.3 next-hop-selfr1(config-router#nei 10.0.0.4 remote-as 65000r1(config-router#nei 10.0.0.4 update-source lo 0r1(config-router#nei 10.0.0.4 next-hop-selfr1(config-router#endr2(config#router bgp 65000r2(config-router#nei 10.0.26.2 remote-as 65001r2(config-router#nei 10.0.0.3 remote-as 65000r2(config-router#nei 10.0.0.3 update-source lo 0r2(config-router#nei 10.0.0.3 next-hop-selfr2(config-router#nei 10.0.0.4 remote-as 65000r2(config-router#nei 10.0.0.4 update-source lo 0r2(config-router#nei 10.0.0.4 next-hop-selfr2(config-router#no sr2(config-router#no aur2(config-router#endr3(config#router bgp 65000r3(config-router#nei fuckjiuge peer-groupr3(config-router#nei fuckjiuge remote-as 65000r3(config-router#nei fuckjiuge update-source lo 0 r3(config-router#nei fuckjiuge next-hop-sr3(config-router#nei fuckjiuge route-reflector-client r3(config-router#nei 10.0.0.1 peer-group fuckjiuge r3(config-router#nei 10.0.0.2 peer-group fuckjiuge r3(config-router#nei 10.0.0.4 remote-as 65000r3(config-router#nei 10.0.0.4 update-source lo 0r3(config-router#nei 10.0.0.4 next-hop-selfr3(config-router#bgp cluster-id 10.0.0.3r3(config-router#no synchronizationr3(config-router#no aur3(config-router#endr4(config#router bgp 65000r4(config-router#no synchronizationr4(config-router#no aur4(config-router#nei fuckjiuge peer-groupr4(config-router#nei fuckjiuge remote-as 65000r4(config-router#nei fuckjiuge update-source lo 0r4(config-router#nei fuckjiuge next-hop-selfr4(config-router#nei fuckjiuge route-reflector-client r4(config-router#nei 10.0.0.1 peer-group fuckjiuger4(config-router#nei 10.0.0.2 peer-group fuckjiuger4(config-router#bgp cluster-id 10.0.0.3r4(config-router#nei 10.0.0.3 remote-as 65000r4(config-router#nei 10.0.0.3 update-source lo 0r4(config-router#nei 10.0.0.3 next-hop-selfr5(config#router bgp 65001r5(config-router#no synchronizationr5(config-router#no aur5(config-router#nei 10.0.15.1 remote-as 65000r5(config-router#neighbor 10.6.0.1 remote-as 65001 r5(config-router#neighbor 10.6.0.1 update-source lo 0 r5(config-router#neighbor 10.6.0.1 next-hop-selfr5(config-router#endr6(config#router bgp 65001r6(config-router#no synchronizationr6(config-router#nei 10.0.26.1 remote-as 65000 r6(config-router#nei 10.5.0.1 remote-as 65001 r6(config-router#nei 10.5.0.1 update-source lo 0 r6(config-router#nei 10.5.0.1 next-hop-selfr6(config-router#end路由注入r3(config#ip route 10.0.0.0 255.255.0.0 null0r3(config#ip route 10.2.0.0 255.255.0.0 null0r3(config#ip route 10.3.0.0 255.255.0.0 null0r3(config#ip route 10.4.0.0 255.255.0.0 null0r3(config#router bgp 65000r3(config-router#net 10.0.0.0 mask 255.255.0.0 r3(config-router#net 10.2.0.0 mask 255.255.0.0 r3(config-router#net 10.3.0.0 mask 255.255.0.0 r3(config-router#net 10.4.0.0 mask 255.255.0.0 r3(config-router#endr4(config#ip route 10.0.0.0 255.255.0.0 null0r4(config#ip route 10.2.0.0 255.255.0.0 null0r4(config#ip route 10.3.0.0 255.255.0.0 null0r4(config#ip route 10.4.0.0 255.255.0.0 null0r4(config#router bgp 65000r4(config-router#net 10.0.0.0 mask 255.255.0.0 r4(config-router#net 10.1.0.0 mask 255.255.0.0 r4(config-router#net 10.2.0.0 mask 255.255.0.0 r4(config-router#net 10.3.0.0 mask 255.255.0.0 r4(config-router#net 10.4.0.0 mask 255.255.0.0r5(config#ip route 10.5.0.0 255.255.0.0 null0r5(config#ip route 10.6.0.0 255.255.0.0 null0r5(config#router bgp 65001r5(config-router#net 10.5.0.0 mask 255.255.0.0r5(config-router#net 10.6.0.0 mask 255.255.0.0r5(config-router#endr6(config#ip route 10.5.0.0 255.255.0.0 null0r6(config#ip route 10.6.0.0 255.255.0.0 null0r6(config#router bgp 65001r6(config-router#net 10.5.0.0 mask 255.255.0.0r6(config-router#net 10.6.0.0 mask 255.255.0.0选路要求的满足要满足选路要求(1)只需要在RT5进RT6的BGP路由中的10.3.0.0的权重加大就行了如下:r6(config#access-list 1 permit 10.3.0.0 0.0.255.255r6(config#route-map fuckjiuge permit 10r6(config-route-map#match ip ad 1r6(config-route-map#set weight 100 //设置权重为100,默认为0r6(config-route-map#exitr6(config#route-map fuckjiuge permit 20 //由于有默认拒绝所以必须加这一条r6(config#router bgp 65001r6(config-router#nei 10.5.0.1 route-map fuckjiuge in查路由表*>i10.3.0.0/16 10.5.0.1 0 100 100 65000 I* 10.0.26.1 0 65000 ir6#show ip bgp 10.3.0.0BGP routing table entry for 10.3.0.0/16, version 8Paths: (2 available, best #1, table Default-IP-Routing-TableFlag: 0x940Advertised to update-groups:16500010.5.0.1 (metric 2 from 10.5.0.1 (10.5.0.1Origin IGP, metric 0, localpref 100, weight 100, valid, internal, best //由选择原则第一条选出最佳路由6500010.0.26.1 from 10.0.26.1 (10.0.0.2Origin IGP, localpref 100, valid, external第二种方法在路由从RT1进RT5时加大10.3.0.0的本地优先级r5(config#ip prefix-list 1 permit 10.3.0.0/16r5(config#route-map fuckjiuge permit 10r5(config-route-map#match ip ad prefix-list 1r5(config-route-map#set local-preference 200 //设置本地优先级为200,默认为100r5(config-route-map#exitr5(config#route-map fuckjiuge permit 20r5(config-route-map#exitr5(config#router bgp 65001r5(config-router#nei 10.0.15.1 route-map fuckjiuge inr5#show ip bgpBGP table version is 12, local router ID is 10.5.0.1Network Next Hop Metric LocPrf Weight Path* i10.0.0.0/16 10.6.0.1 0 100 0 65000 i*> 10.0.15.1 0 65000 i* i10.2.0.0/16 10.6.0.1 0 100 0 65000 i*> 10.0.15.1 0 65000 i* i10.3.0.0/16 10.6.0.1 0 100 0 65000 i*> 10.0.15.1 200 0 65000 I //优先级变200了r6#show ip bgpBGP table version is 10, local router ID is 10.6.0.1Network Next Hop Metric LocPrf Weight Path* i10.0.0.0/16 10.5.0.1 0 100 0 65000 i*> 10.0.26.1 0 65000 i* i10.2.0.0/16 10.5.0.1 0 100 0 65000 i*> 10.0.26.1 0 65000 i*>i10.3.0.0/16 10.5.0.1 0 200 0 65000 I //由于本地优先级在AS内传递所以RT6关于10.3.0.0的本地优先级也是200* 10.0.26.1 0 65000 i第三种方法改从RT2出来的10.3.0.0的MED值r2(config#access-list 1 permit 10.3.0.0 0.0.255.255r2(config#route-map fuckjiuge permit 10r2(config-route-map#match ip ad 1r2(config-route-map#set metric 5 //MED值设为5默认为0。
BGP选路原则(决策过程)1.优选有最大Weight的路由(范围0 到65,535)A:weight是CISCO私有的参数,路由器配置了权重后在本地有效。
2.优选有最大LOCAL_PREF值的路由(范围0到4,294,967,295).3.优选从本路由器始发的路由(包括本地network配置的重分布,或者在IGP表中已经有一些需要被配置路由聚合的地址,在BGP中用Aggregate命令配置的路由聚合,)4.优选有最短AS_PATH的路由A.如果配置了Bgp bestpath as-path ignore,则这个步骤被忽略B.一个AS路径集被当作一个AS,无论在这个集合中有多少AS。
C.AS路径长度中没有包括AS_CONFED_SEQUENCE。
5.根据Origin属性.优选具有最低起源类型的路由(IGP>EG>Incomplete)6.优选最小MED 值的路由(范围0到4,294,967,295).A.只有在通过两条路径得到第一个AS(对等体)是同一个AS时才进行MED比较;任何子自治域的联盟系统都会被忽略。
也就是说,只有在AS序列号中第一个AS号码一致时,才进行MED比较;任何联盟AS序列号(AS_CONFED_SEQUENCE)都会被忽略。
B.如果路由器上配置了bgp always—compare—med ,在全部的路径进行MED比较。
但是这需要全体AS 都同时启用这个功能,否则有可能发生路由环路。
C.如果路由器上配置了bgp bestpath med confed ,将对所有只包括AS_CONFED_SEQUENCE的路径进行MED比较(即路径是起源于本地联盟)。
D.如果接收到的路径没有分配MED值,则将此路径分配为0,除非路由器上配置了bestpath missing—is—worst,将被看作MED值为4,294,967,295的路由将在注入到BGP路由选择表之前被改为4,294 ,967,294。
BGP选路规则实验1.使R1,R2,R3,R4全网建立BGP,并且互通(1)将R3加入BGP中R1:r1(config)#router bgp 1r1(config-router)#neighbor 3.3.3.3 remote-as 1r1(config-router)#neighbor 3.3.3.3 update-source loopback 0R3:r3(config)#router bgp 1r3(config-router)#bgp router-id 3.3.3.3r3(config-router)#neighbor 1.1.1.1 remote-as 1r3(config-router)#neighbor 1.1.1.1 update-source loopback 0r3(config-router)#neighbor 4.4.4.4 remote-as 4r3(config-router)#neighbor 4.4.4.4 update-source loopback 0r3(config-router)#neighbor 4.4.4.4 ebgp-multihopR4:r4(config)#router bgp 4r4(config-router)#neighbor 3.3.3.3 remote-as 1r4(config-router)#neighbor 3.3.3.3 update-source loopback 0r4(config-router)#neighbor 3.3.3.3 ebgp-multihop(2)查看R3的BGP邻居r3#sh ip bg summaryBGP router identifier 3.3.3.3, local AS number 1BGP table version is 4, main routing table version 43 network entries using 351 bytes of memory3 path entries using 156 bytes of memory3/2 BGP path/bestpath attribute entries using 372 bytes of memory 1 BGP AS-PATH entries using 24 bytes of memory0 BGP route-map cache entries using 0 bytes of memory0 BGP filter-list cache entries using 0 bytes of memoryBGP using 903 total bytes of memoryBGP activity 3/0 prefixes, 3/0 paths, scan interval 60 secsNeighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd1.1.1.1 4 1 7 7 4 0 0 00:02:08 14.4.4.4 4 4 7 5 4 0 0 00:00:08 2r3#说明:R3已经与其它路由器建立BGP邻居。
2.改变AS 1内部下一跳(1)查看R1的BGP路由表r1#sh ip bgpBGP table version is 6, local router ID is 1.1.1.1Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path*> 11.1.1.0/24 0.0.0.0 0 32768 i*>i22.2.2.0/24 2.2.2.2 0 100 0 ?* i44.4.4.0/24 4.4.4.4 0 100 0 4 i*>i 4.4.4.4 0 100 0 4 ir i100.1.1.0/24 4.4.4.4 0 100 0 4 ir>i 4.4.4.4 0 100 0 4 ir1#说明:因为R1都是从iBGP收到的路由,所以到达R4的路由44.4.4.0的下一跳都为4.4.4.4,而没有被R2和R3改变。
(2)改变R2与R3对R1的下一跳为自己r2(config)#router bgp 1r2(config-router)#neighbor 1.1.1.1 next-hop-selfr3(config)#router bgp 1r3(config-router)#neighbor 1.1.1.1 next-hop-self(3)再次查看R1的BGP路由表r1#sh ip bgpBGP table version is 8, local router ID is 1.1.1.1Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path*> 11.1.1.0/24 0.0.0.0 0 32768 i*>i22.2.2.0/24 2.2.2.2 0 100 0 ?* i44.4.4.0/24 3.3.3.3 0 100 0 4 i*>i 2.2.2.2 0 100 0 4 ir i100.1.1.0/24 3.3.3.3 0 100 0 4 ir>i 2.2.2.2 0 100 0 4 ir1#说明:学习到的路由44.4.4.0/24已经被R2和R3改为自己。
测试选路规则说明:测试R1通过R2与R3到达R4的网段44.4.4.0/24的选路,以及测试R4通过R2与R3到达R1的网段11.1.1.0/24的选路,要测试的选路顺序为1.最高Weight值2.最高LOCAL_PREF值3.本地发起路由4.最短AS_PATH5.最低Origin类型6.最小MED值7.eBGP优于iBGP8.最小IGP metric到达下一跳的路由9.负载均衡(如果开启的话)10.如果下一跳都为eBGP,则选择最早学习到的路由(即时间最长的路由)11.最低Router-ID下一跳12.最短cluster list(如同AS_PATH)13.最小下一跳的邻居地址因为选路顺序为由上至下,当上一个属性已经比较出最优路径,则下一属性被忽略,所以我们实验从下往上修改来进行比较,因为改过下面的属性影响选路之后,只要再改上一条,就能再次影响选路,就能证明,上一条是比下一条优先的。
测试第13条最小下一跳的邻居地址说明:因为只有下一跳邻居的Router-ID相同的情况下,才会比较下一跳邻居的地址大小,所以先将R2与R3的Router-ID改为相同,以测试比较下一跳地址。
(1)修改R3的Router-ID与R2相同r3(config)#router bgp 1r3(config-router)#bgp router-id 2.2.2.2r3(config-router)#(2)查看R1到达44.4.4.0/24的选路r1#sh ip bgpBGP table version is 8, local router ID is 1.1.1.1Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path*> 11.1.1.0/24 0.0.0.0 0 32768 i*>i22.2.2.0/24 2.2.2.2 0 100 0 ?* i44.4.4.0/24 3.3.3.3 0 100 0 4 i*>i 2.2.2.2 0 100 0 4 ir i100.1.1.0/24 3.3.3.3 0 100 0 4 ir>i 2.2.2.2 0 100 0 4 ir1#说明:R1到达网段44.4.4.0/24选则最小下一跳邻居R2为最优路径。
测试第12条最短cluster list说明:因为比较最短cluster list只在BGP Route Reflector (RR)环境中才有,所以此步跳过。
测试第11条最低Router-ID下一跳说明:选择下一跳有最小Router-ID的邻居为最优路径。
(1)修改R3的Router-IDr3(config)#router bgp 1r3(config-router)#bgp router-id 1.1.1.3说明:将R3的Router-ID改为1.1.1.3(2)查看R1到达44.4.4.0/24的选路r1#sh ip bgpBGP table version is 10, local router ID is 1.1.1.1Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path*> 11.1.1.0/24 0.0.0.0 0 32768 i*>i22.2.2.0/24 2.2.2.2 0 100 0 ?*>i44.4.4.0/24 3.3.3.3 0 100 0 4 i* i 2.2.2.2 0 100 0 4 ir>i100.1.1.0/24 3.3.3.3 0 100 0 4 ir i 2.2.2.2 0 100 0 4 ir1#说明:因为R2的Router-ID为2.2.2.2,而R3的Router-ID为1.1.1.3,所以最小Router-ID的R3被选为最优路径。