C-BGP使用技巧

    技术2025-07-13  18

    1 配置静态路由时,必须加上--oif指定出接口才可以保证IP连通性。例如

     

    net add node 0.1.0.0net add node 0.2.0.0net add link 0.1.0.0 0.2.0.0

    print "Specifying the static route/n"net node 0.1.0.0 route add 0.2.0.0/32 --oif=0.2.0.0/32 0net node 0.2.0.0 route add 0.1.0.0/32 --oif=0.1.0.0/32 0

     

    这是因为你通过net node 0.1.0.0 show ifaces就可以看到有这样一个条目:

    rtr 0.2.0.0/32。这样在转发表中才安装了包含正确的下一跳的路由条目,通过net node 0.1.0.0 show rt *可以看到为:

    0.2.0.0/32 0.0.0.0 0.2.0.0 0 STATIC

     

     

    2 配置BGP时,如果要把ebgp邻居宣告的路由正确宣告给ibgp邻居,则ebgp邻居在配置时必须增加peer x next-hop-self的命令。

    例如下面的配置:

     

    print "The first trick is to use --oif when you specify the static route! I'm sorry, but fuck this trick!/n"print "The second trick is to use next-hop-self when you specify ebgp session! I'm sorry, but fuck this trick 2!/n"

    net add node 0.1.0.0net add node 0.2.0.0net add node 0.3.0.0net add link 0.1.0.0 0.2.0.0net add link 0.2.0.0 0.3.0.0

    net node 0.1.0.0 route add 0.2.0.0/32 --oif=0.2.0.0/32 0net node 0.2.0.0 route add 0.1.0.0/32 --oif=0.1.0.0/32 0#net node 0.2.0.0 route add 0.3.0.0/32 --oif=0.3.0.0/32 0#net node 0.3.0.0 route add 0.2.0.0/32 --oif=0.2.0.0/32 0

    bgp add router 1 0.1.0.0bgp router 0.1.0.0        add network 0.1/16        add peer 2 0.2.0.0        peer 0.2.0.0 next-hop-self        peer 0.2.0.0 up

    net add domain 2 igpnet node 0.2.0.0 domain 2net node 0.3.0.0 domain 2net link 0.2.0.0 0.3.0.0 igp-weight --bidir 1net domain 2 compute

    bgp add router 2 0.2.0.0

    bgp add router 2 0.3.0.0bgp domain 2 full-meshbgp router 0.2.0.0        add peer 1 0.1.0.0        peer 0.1.0.0 next-hop-self#       add peer 2 0.3.0.0        peer 0.1.0.0 up#       peer 0.3.0.0 next-hop-self#       peer 0.3.0.0 up

    #bgp add router 2 0.3.0.0bgp router 0.3.0.0        add network 0.3/16#       add peer 2 0.2.0.0#       peer 0.2.0.0 next-hop-self#       peer 0.2.0.0 up

    sim run

    print "Again, Let's check it now!/n"net node 0.1.0.0 ping 0.3.0.0

    print "Again, we can trace the path/n"net node 0.1.0.0 record-route 0.3.0.0net node 0.3.0.0 record-route 0.1.0.0

     

    这时通过 router 0.3.0.0 show adj-rib in 0.2.0.0 *命令查看到的才是正确的入路由条目:

    *> 0.1.0.0/16 0.2.0.0 0 4294967295 1 i

    否则看到的永远是无效的 0.1.0.0/16 0.1.0.0 0 4294967295 1 i.

    看出这细微的差别了吗?

     

    如果是把ebgp邻居宣告的路由正确宣告给其他ebgp邻居,则不需要这样!

     

    在导入Internet一级的拓扑文件时,比如来自CAIDA格式的Internet topology(http://www.caida.org/data/active/as-relationships),通常是使用bgp topology load/install/policies/run等这些命令。

    用完之后,C-BGP会按照拓扑文件里面的自治系统商业关系来生成了拓扑中的宣告序列,保证了其中的valley-free特性。

    当然,这些商业关系是使用C-BGP中的filter来实现的,查看已经生成的这些路由策略的方式是:

    bgp router X

       peer Y

         filter in|out show即可

    当然,你还可以在这些基本商业关系策略的基础上add-rule/insert-rule/remove-rule。

    由此可见,C-BGP在对路由策略的支持上还是很强的。

     

    最新回复(0)