这里EGP使用物理口相互创建邻居,IGP使用环回口创建邻居 物理口创建邻居不须要学习到对方的环回口----方便 环回口创建邻居比较稳定---稳定(只要还要一个物理口为up则一直为up)
R1:负载均衡
//需注意是从用户模式开始配置的 en conf t hostname R1 int lo1 ip add 1.1.1.1 255.255.255.255 no sh int f0/0 ip add 12.1.1.1 255.255.255.0 no sh int f1/0 ip add 24.1.1.1 255.255.255.0 no sh router bgp 100 bgp router-id 1.1.1.1 nei 12.1.1.2 remote-as 1 nei 24.1.1.3 remote-as 1 net 1.1.1.1 mask 255.255.255.255 //必须与路由表中的相一致 exit do wr //保存配置,方便后续实验
R2:ide
en conf t hostname R2 int f0/0 ip add 12.1.1.2 255.255.255.0 no sh exit int lo1 ip add 2.2.2.2 255.255.255.255 no sh exit int f1/0 ip add 32.1.1.2 255.255.255.0 no sh exit router bgp 1 bgp router-id 2.2.2.2 nei 12.1.1.1 remote-as 100 nei 4.4.4.4 remote-as 1 nei 4.4.4.4 update-source lo1 //修改更新源---默认互联物理口(即TCP报文从那里发出去) nei 4.4.4.4 next-hop-self //你们能够试试不加这条命令 exit router eigrp 100 net 12.1.1.0 0.0.0.255 net 32.1.1.0 0.0.0.255 net 2.2.2.2 0.0.0.0 //为了后面IGP邻居可以创建起邻居 exit IGP学习到外部EBGP的路由,原封不动发送给IGP邻居的,若是不指定下一跳,则会致使不是最优(也去不了)R2去R1环回口默认是直接发送给R1,而R3根本不可能直接发送给R1。(链接不一样AS路由器上作)
R4:学习
en conf t hostname R4 int f0/0 ip add 32.1.1.4 255.255.255.0 no sh exit int lo0 ip add 11.11.11.11 255.255.255.255 no sh int lo1 ip add 4.4.4.4 255.255.255.255 no sh exit int s2/0 ip add 52.1.1.4 255.255.255.255 no sh exit router bgp 1 bgp router-id 4.4.4.4 nei 2.2.2.2 remote-as 1 nei 2.2.2.2 update-source lo1 nei 3.3.3.3 remote-as 1 nei 3.3.3.3 update-source lo1 exit router eigrp 100 net 32.1.1.0 0.0.0.255 net 4.4.4.0 0.0.0.255 net 52.1.1.0 0.0.0.255 exit
R3:code
en conf t hostname R3 int f0/0 ip add 24.1.1.3 255.255.255.0 no sh exit int lo1 ip add 3.3.3.3 255.255.255.255 no sh exit int s2/0 ip add 52.1.1.3 255.255.255.0 no sh exit router bgp 1 bgp router-id 3.3.3.3 nei 24.1.1.1 remote-as 100 nei 4.4.4.4 remote-as 1 nei 4.4.4.4 next-hop-self nei 4.4.4.4 update-source lo1 exit router eigrp 100 net 52.1.1.0 0.0.0.255 net 3.3.3.3 0.0.0.0 net 24.1.1.0 0.0.0.255 exit do wr
(你们要看看R4的s2/0起来没有,我这边就是要多打一边)--
咱们能够看到R4经过学习到R1的1.1.1.1的路由,最优的()是
>i1.1.1.1/32 2.2.2.2 router
传播范围:本路由内(不可传递)
缺省值:本路由器=32768,其余=0
两种配置方法:blog
如今R4去往1.1.1.1走的是R2,咱们来对它进行修改,使其走向R3ip
Network Next Hop Metric LocPrf Weight Path *>i1.1.1.1/32 2.2.2.2 0 100 0 100 i * i 3.3.3.3 0 100 0 100 i *> 11.11.11.11/32 0.0.0.0 0 32768 i
R4:ci
//用户模式开始 en conf t router bgp 1 neighbor 3.3.3.3 weight 100 //将邻居3.3.3.3发送的条目权重值改成100 记得在特权模式下软清一下:clear ip bgp * so ———————————————————————————————————————————————————————————————————————————————————————————— 能够看到确实是走R3了 Network Next Hop Metric LocPrf Weight Path * i1.1.1.1/32 2.2.2.2 0 100 0 100 i *>i 3.3.3.3 0 100 100 100 i *> 11.11.11.11/32 0.0.0.0 0 32768 i 确实是很方便,可是会致使什么状况呢! 你们看我在R1再宣告一条路由 en conf t int lo2 ip add 8.8.8.8 255.255.255.255 no sh exit router bgp 100 net 8.8.8.8 mask 255.255.255.255 再看R4的BGP路由表 Network Next Hop Metric LocPrf Weight Path * i1.1.1.1/32 2.2.2.2 0 100 0 100 i *>i 3.3.3.3 0 100 100 100 i *>i8.8.8.8/32 3.3.3.3 0 100 100 100 i * i 2.2.2.2 0 100 0 100 i *> 11.11.11.11/32 0.0.0.0 0 32768 i 仍是走R3--就有点不太灵活了!
利用前缀列表或access-list抓取相应的条目
R4:路由
en conf t access-list 10 permit 1.1.1.1 //抓取对应的条目 route-map Weight permit //route-map来修改权重 match ip address 10 //绑定咱们写好的ACL列表 set weight 100 exit router bgp 1 neighbor 3.3.3.3 route-map Weight in //接收方向调用 //这样咱们能够看到只有R3传过来的1.1.1.1 才会加100weight Network Next Hop Metric LocPrf Weight Path * i1.1.1.1/32 2.2.2.2 0 100 0 100 i *>i 3.3.3.3 0 100 100 100 i *>i8.8.8.8/32 2.2.2.2 0 100 0 100 i *> 11.11.11.11/32 0.0.0.0 0 32768 i
传播范围:AS内进行传播
缺省值:100
比较方式:越大越优
一样R4去往1.1.1.1 走R3rem
R3:
//用户模式开始配置 en conf t router bgp 1 bgp default locall-preference 110 //软清理一下 R3#clear ip bgp * so //没有so则硬清,生产环境不要硬清
R4上查看:
Network Next Hop Metric LocPrf Weight Path * i1.1.1.1/32 2.2.2.2 0 100 0 100 i *>i 3.3.3.3 0 110 0 100 i *>i8.8.8.8/32 3.3.3.3 0 110 0 100 i * i 2.2.2.2 0 100 0 100 i *> 11.11.11.11/32 0.0.0.0 0 32768 i //确实是能够,与上面状况一致,不太灵活
R4:
//用户模式开始配置 en conf t access-list 10 permit 1.1.1.1 //抓取路由条目 route-map Local permit match ip address 10 //与ACL相绑定 set local-preference 110 //修改本地优先级 exit router bgp 1 neighbor 3.3.3.3 route-map Local in //in方向进行调用 查看R4 BGP路由表 Network Next Hop Metric LocPrf Weight Path * i1.1.1.1/32 2.2.2.2 0 100 0 100 i *>i 3.3.3.3 0 110 0 100 i *>i8.8.8.8/32 2.2.2.2 0 100 0 100 i *> 11.11.11.11/32 0.0.0.0 0 32768 i 咱们看到只有3.3.3.3发出来的条目1.1.1.1被加上*>和对应的本地优先级
R3:
//用户模式开始配置 en conf t ip prefix-list Local-out permit 1.1.1.1/32 //前缀列表抓取条目 route-map Local-out permit match ip address prefix-list Local-out //绑定前缀列表 set local-preference 120 //修改BGP本地优先级 exit router bgp 1 nei 4.4.4.4 route-map Local-out out //out方向调用
R4 BGP路由:
Network Next Hop Metric LocPrf Weight Path * i1.1.1.1/32 2.2.2.2 0 100 0 100 i *>i 3.3.3.3 0 120 0 100 i *>i8.8.8.8/32 2.2.2.2 0 100 0 100 i *> 11.11.11.11/32 0.0.0.0 0 32768 i
R1上看去往1.1.1.1下一跳是否是0.0.0.0
作个小案例:
R4:
//用户模式开始配置 //R4去往1.1.1.1 这个路由通常走R2或R3 en conf t ip route 1.1.1.1 255.255.255.255 null 0 router bgp 1 net 1.1.1.1 mask 255.255.255.255 exit do sh ip bgp //相信本身,将Next Hop改成本身0.0.0.0 Network Next Hop Metric LocPrf Weight Path *> 1.1.1.1/32 0.0.0.0 0 32768 i
若是收到本区域的AS则丢弃
边界路由器上作,针对对方IGP内
R1:
en conf t access-list 10 permit 1.1.1.1 route-map AS-Path match ip address 10 set as-path prepend 2 4 5 6 7 8 exit router bgp 1 neighbor 12.1.1.2 route-map AS-Path out
R1:
en conf t access-list 10 permit 1.1.1.1 route-map AS-Path match ip address 10 set as-path prepend 1 2 4 5 6 7 8 exit router bgp 1 neighbor 12.1.1.2 route-map AS-Path out R2直接就丢弃了(气死我了)
强制要求R2接收(嘿嘿)
R2-in方向:
//用户模式配置 en conf t router bgp 1 neighbor 12.1.1.1 allowas-in 再来查看R2的BGP路由表: Network Next Hop Metric LocPrf Weight Path *> 1.1.1.1/32 12.1.1.1 0 0 100 1 2 3 4 5 6 7 8 i *>i11.11.11.11/32 4.4.4.4 0 100 0 i
//用户模式配置 en conf t router bgp 1 bgp maxas-limit [数量] R5(config-router)#bgp bestpath as-path ignore //忽略AS-path