BGP local-preference 试验

拓扑:

因为BGP的local-preference默认为100,而BGP默认选择local-preference较大的值作为下一跳

 

local-preference配置:在本地配置影响IBGP对等体出站

R1的配置:

Router>en

Router#conf t

Router(config)#host R1

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 fa0/0

R1(config-if)#ip add 10.4.4.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 rip    (bgp的底层协议我起的RIP)

R1(config-router)#ver 2

R1(config-router)#no au

R1(config-router)#net 1.0.0.0

R1(config-router)#net 10.0.0.0

R1(config-router)#end

R1(config)#int lo 1

R1(config-if)#ip add 100.100.100.100 255.255.255.0

R1(config-if)#no sh

R1(config-if)#exi

R1(config)#router bgp 100

R1(config-router)#net 100.100.100.0 mask 255.255.255.0   (公告100.100.100.0/24网段)

R1(config-router)#nei 2.2.2.2 remote 100

R1(config-router)#nei 2.2.2.2 update-source loopback 0 (指定更新源是LOOPBACK 0)

R1(config-router)#nei 4.4.4.4 remote 200

R1(config-router)#nei 4.4.4.4 update-source lo 0

R1(config-router)#nei 4.4.4.4 ebgp-multihop 2 (ebgp建立邻居时要配置)

 

R2 R3 R4 的配置与R1的类似

 

现在我们查看R3 R4的bgp路由表:

R3#sh ip bgp

BGP table version is 3, 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

* i100.100.100.0/24    1.1.1.1                  0    100       0 100 i

*>                  2.2.2.2                                 0 100 i

* i200.200.200.0       1.1.1.1                  0    100       0 100 i

*>                  2.2.2.2                   0              0 100 i

 

R4#sh ip bgp

BGP table version is 3, local router ID is 4.4.4.4

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

* i100.100.100.0/24    2.2.2.2                  0    100      0 100 i

*>                  1.1.1.1                  0             0 100 i

* i200.200.200.0       2.2.2.2                  0    100      0 100 i

*>                  1.1.1.1                                0 100 i

发现R3 学到100.100.100.0/24 网络和200.200.200.0/24网络都是从R2学到的

发现R4 学到100.100.100.0/24 网络和200.200.200.0/24网络都是从R1学到的

这是为什么呢?为什么不是R3学到100.100.100.0/24 网络从R1而学200.200.200.0/24网络都是从R2学到呢?

这是因为EBGP优与IBGP

 

 

现在在R4上做local-preference来影响R3出站:让R3学到100.100.100.0/24 是从R1学到的。

 

R4(config)#access-list 1 per 100.100.100.0 0.0.0.255 (标示出要施加策略的网络)

R4(config)#route-map ccxx per 10                   (写ROUTE-MAP)

R4(config-route-map)#ma ip add 1

R4(config-route-map)#set local-preference 200          (改变local-preference值,越大越优)

R4(config-route-map)#exi

R4(config)#route-map ccxx per 20                      (写一个空ROUTE-MAP)

R4(config-route-map)#exi

R4(config)#router bgp 200

R4(config-router)#nei 1.1.1.1 route-map ccxx in            (套用ROUTE-MAP)

 

再查看R3 R4的BGP路由表:

R3#sh ip bgp

BGP table version is 4, 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

*>i100.100.100.0/24   1.1.1.1            0    200      0 100 I (变了吧!!(=^ ^=))

*                   2.2.2.2                           0 100 i

* i200.200.200.0       1.1.1.1              0    100      0 100 i

*>                  2.2.2.2               0             0 100 i

 

R4#sh ip bgp

BGP table version is 4, local router ID is 4.4.4.4

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

*> 100.100.100.0/24   1.1.1.1                  0    200      0 100 i

* i200.200.200.0    2.2.2.2                  0    100      0 100 i

*>                  1.1.1.1                                0 100 i

 

Cisco CCIE Security 2009 IOS防火墙合集

Cisco CCIE Security 2009最新整套视频合集

dada147 2009 ccnp新版交换视频集合

CCIE 路由与交换 CCIE SP 服务提供商
CCIE R&S v4.0 LAB 版本 k1 + k2 + k3 分享 转帖

现任明教教主共享TCPIP课程(2008年最新录制)2008.6.18

现任明教教主视频汇总

JUNOS Enterprise Routing

 

秦柯 08 CCIE PIX 分解实验 一

秦柯 08 CCIE pix 视频分享 1-2集
Catalyst 6500 Lab Virtual Switching System VSS--中文
F5 中国解决方案
Cisco 交换机6509配置实例(双机热备)

H3C与cisco互联问题技术交流汇总
F5 链路负载均衡方案模板
F5 FirePass功能配置手册

Cisco 6500 FWSM防火墙模块配置和实验案例

Cisco ASA 5500 系列产品售后实施文档
Cisco ASA and PIX Firewall Handbook

 

Juniper视频如何购买

CCSP视频下载

Juniper 视频购买

Cisco CCNP+TSHOOT+642-832+中文 高清扫描版

新版 CCNP 学习用书 CCNP SWITCH 642-813

新版 CCNP 学习用书 CCNP ROUTE 642-902

新版 CCNP 学习用书 CCNP TSHOOT 642-832

 

[已更新] 秦柯TCP-IP协议基础视频(含PPT文档共960MB)

文章转载至http://bbs.net527.cn   无忧网客联盟

shop.net527.cn/

无忧网客联盟主站

无忧linux时代

### 含义 BGP(Border Gateway Protocol)中的 `default local-preference` 是一个路由属性,用于表明路由器的BGP优先级,用于判断流量离开AS时的优选路由。当BGP的设备通过不同的IBGP对等体得到目的地址相同但下一跳不同的多条路由时,将优先选择Local_Pref属性值较高的路由。如果路由没有配置Local_Pref属性,BGP选路时将该路由的Local_Pref值按缺省值100来处理 [^2]。 ### 作用 `default local-preference` 的主要作用是控制BGP网络内部的流量走向。由于 Local_Pref 属性仅在IBGP对等体之间有效,不通告给其他AS,因此可以在自治系统(AS)内部,通过调整 Local_Pref 的值来决定本地AS向外部AS发送流量时的优选出口,以实现流量的合理分配和优化路由选择 [^2]。 ### 使用方法 以下是在不同场景下使用 `default local-preference` 的示例: #### 查看BGP协议的默认参数 可以使用 `display default-parameter bgp` 命令查看BGP协议的默认参数,其中可能包含默认的 `local-preference` 值 [^1]。 ```plaintext [R3]display default-parameter bgp ``` #### 手动配置 Local_Preference 可以通过配置访问控制列表(ACL)和路由策略(route-map)来手动配置 Local_Preference。以下是一个锐捷设备的配置示例 [^4]: ```plaintext R6(config)#access-list 10 permit 192.168.1.0 0.0.254.255 //匹配单数网段的IP R6(config)#access-list 20 permit 192.168.2.0 0.0.254.255 //匹配双数网段的IP R6(config)#route-map lp permit 10 R6(config-route-map)# match ip address 10 R6(config-route-map)# set local-preference 50 //设置单数条目权重 R6(config)#route-map lp permit 20 R6(config-route-map)# match ip address 20 R6(config-route-map)# set local-preference 150 //设置双数条目权重 R6(config)#route-map lp permit 30 //用于允许其他所有 R6(config)#router bgp 10 R6(config-router)# neighbor 8.8.8.8 route-map lp out //调用,在R6向R8方向发送 ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值