Routing

last person joined: 2 days ago 

Ask questions and share experiences about ACX Series, CTP Series, MX Series, PTX Series, SSR Series, JRR Series, and all things routing, including portfolios and protocols.
Expand all | Collapse all

AS-Path Prepending in Junos

  • 1.  AS-Path Prepending in Junos

    Posted 04-15-2012 04:57

    Hi! We have to edge routers one is Cisco and other is Juniper M7i. Both have BGP running with our ISP. Currently incoming traffic from ISP into our network is coming through M7i interface. I want to make Cisco link more preferred or(M7i link less preferred). For this we can use AS-Path prepending on M7i right?

     

    So I want to be sure how would you configure that in Juniper. If it was Cisco I would have done something like this:

    router bgp 65001
     neighbor 4.35.56.2 remote-as 45465
     neighbor 4.35.56.2 route-map prepend out
    !
    route-map prepend permit 10
     set as-path prepend 24367 25367 25367

     

    So in Junos does the follwoing configuration seem ok?

     

    protocols {
        bgp {
            group STC {
                import FROM_STC;
                export TO_STC;
                neighbor 4.35.56.2 {
                    local-address 4.35.56.1;
                    peer-as 45465;
                }
            }
           
            }
               
        
    }

    policy-options {
        policy-statement FROM_STC {
            term 1 {
                from {
                    route-filter 0.0.0.0/0 exact;
                }
                then accept;
            }
            term 2 {
                then reject;
            }
        }
        policy-statement TO_STC {
            term 1 {
                from {
                    protocol direct;
                    route-filter 13.17.102.0/24 orlonger;
                }
                then{
            as-path-prepend " 24367 25367 25367";
             accept;
            }
            }
            term 2 {

                then reject;
            }
        }
    }



  • 2.  RE: AS-Path Prepending in Junos

    Posted 04-16-2012 01:48

    If your incoming traffic is only destinated to 13.17.102.0/24 (orlonger) network , then the config looks fine...



  • 3.  RE: AS-Path Prepending in Junos

    Posted 04-16-2012 05:20

    You are only prepending in one direction. If you want the traffic to be symmetric you might want to prepend your ISPs ASn on the import in the same matter.

     

    /K



  • 4.  RE: AS-Path Prepending in Junos

    Posted 04-16-2012 08:35

    Thanks for your reply, well I tried this config but still traffic was coming in via Juniper because I think looking at the looking glass it seemed that juniper is advertising 13.17.102.0/27 and Cisco is advertisisng 13.17.102.0/24. I think its because of the " from protocol direct" keyword as both routers have /27 ip address on their interface to ISP. 

     

    How would i make juniper to advertise /24 address?



  • 5.  RE: AS-Path Prepending in Junos
    Best Answer

    Posted 04-16-2012 08:53

        policy-statement TO_STC {
            term 1 {
                from {
                    protocol static; <------
                    route-filter 13.17.102.0/24 exact;  <------
                }
                then{
            as-path-prepend " 24367 25367 25367";
             accept;
            }
            }
            term 2 {

                then reject;
            }
        }
    }

     

     

    Also make sure you have the /24 prefix in routing table:

    set routing-options static route 13.17.102.0/24 discard

     

     



  • 6.  RE: AS-Path Prepending in Junos

    Posted 10-30-2014 19:50

    Hi ggglabs,

     

    Can you explain the values 'as-path-prepend " 24367 25367 25367" '

    Can we input any value or must the AS number of the router on our side?

     

    Thanks,



  • 7.  RE: AS-Path Prepending in Junos

     
    Posted 10-30-2014 20:22

    Hi sanditehendi,

     

    You can input any values, but since you are sending this to internet we dont know if someone else is also using these values. Better you put your AS values .

     

    Thanks,

    Suraj



  • 8.  RE: AS-Path Prepending in Junos

    Posted 10-30-2014 23:30

    Hi rsuraj,

     

    Thanks for your reply.

    So can I type more than 3 times my AS-number like 'as-path-prepend "65001 65001 65001 65001" '?

    How to calculate which path is longer?

    If the path is longer on one ISP then it will be routed from there, right?

     

    Thanks,



  • 9.  RE: AS-Path Prepending in Junos

     
    Posted 10-30-2014 23:36

    Yes, can typer morethan 3 times.. Reagrding path selection, shortest AS path is preferred

     

     

    So if you advertise as below, first one will be preferred and packet will be routed via that

     

    1. as-path-prepend "65001 65001 65001 65001" 

    2. as-path-prepend "65001 65001 65001 65001 65001 65001" 

     

    Thanks,

    Suraj

    Please Mark My Solution Accepted if it Helped, Kudos are Appreciated too



  • 10.  RE: AS-Path Prepending in Junos

    Posted 11-01-2014 00:25

    The shortest AS path will be prefered 1st..The prepending. You can prepend as many times as you want.. But when you run BGP consider its rules 1st and what happens 1st. Remember the Juniper path selection is slightly different from Cisco as well.. If you are using private AS# don't worry as commented before that if someone else is using it, This will not affect you even if on the same router. Private is private and having said that you will not see their routes and they will not see yours..

     

    1. Verify that the next hop can be resolved.
    2. Choose the path with the lowest preference value (routing protocol process preference).

      Routes that are not eligible to be used for forwarding (for example, because they were rejected by routing policy or because a next hop is inaccessible) have a preference of –1 and are never chosen.

    3. Prefer the path with higher local preference.

      For non-BGP paths, choose the path with the lowest preference2 value.

    4. If the accumulated interior gateway protocol (AIGP) attribute is enabled, prefer the path with the lower AIGP attribute.
    5. Prefer the path with the shortest autonomous system (AS) path value (skipped if the as-path-ignore statement is configured).

      A confederation segment (sequence or set) has a path length of 0. An AS set has a path length of 1.

    6. Prefer the route with the lower origin code.

      Routes learned from an IGP have a lower origin code than those learned from an exterior gateway protocol (EGP), and both have lower origin codes than incomplete routes (routes whose origin is unknown).

    7. Prefer the path with the lowest multiple exit discriminator (MED) metric.

      Depending on whether nondeterministic routing table path selection behavior is configured, there are two possible cases:

      • If nondeterministic routing table path selection behavior is not configured (that is, if the path-selection cisco-nondeterministicstatement is not included in the BGP configuration), for paths with the same neighboring AS numbers at the front of the AS path, prefer the path with the lowest MED metric. To always compare MEDs whether or not the peer ASs of the compared routes are the same, include the path-selection always-compare-med statement.
      • If nondeterministic routing table path selection behavior is configured (that is, the path-selection cisco-nondeterministicstatement is included in the BGP configuration), prefer the path with the lowest MED metric.

      Confederations are not considered when determining neighboring ASs. A missing MED metric is treated as if a MED were present but zero.

       

      By default, only the MEDs of routes that have the same peer autonomous systems (ASs) are compared. You can configure routing table path selection options to obtain different behaviors.

    8. Prefer strictly internal paths, which include IGP routes and locally generated routes (static, direct, local, and so forth).
    9. Prefer strictly external BGP (EBGP) paths over external paths learned through internal BGP (IBGP) sessions.
    10. Prefer the path whose next hop is resolved through the IGP route with the lowest metric.
      If both paths are external, prefer the currently active path to minimize route-flapping. This rule is not used if any one of the following conditions is true:
      • path-selection external-router-id is configured.
      • Both peers have the same router ID.
      • Either peer is a confederation peer.
      • Neither path is the current active path.
    11. Prefer a primary route over a secondary route. A primary route is one that belongs to the routing table. A secondary route is one that is added to the routing table through an export policy.
    12. Prefer the path from the peer with the lowest router ID. For any path with an originator ID attribute, substitute the originator ID for the router ID during router ID comparison.
    13. Prefer the path with the shortest cluster list length. The length is 0 for no list.
    14. Prefer the path from the peer with the lowest peer IP address.

     

     



  • 11.  RE: AS-Path Prepending in Junos

    Posted 11-03-2014 02:10

    Hi aaron,

     

    Thanks for your explanation.

     



  • 12.  RE: AS-Path Prepending in Junos

    Posted 11-03-2014 02:09

    Hi Suraj

     

    Thanks for your explanation.

    And sorry because I can't do option "Mark My Solution Accepted", because this is not my thread.

    Give you kudo instead.