[j-nsp] BGP import policy to accept prefixes from advertising AS only.

Hannes Gredler hannes at juniper.net
Thu Oct 14 05:24:31 EDT 2004


On Thu, Oct 14, 2004 at 01:21:15AM +0100, John Senior wrote:
| Hi all,
| 
| I am sure I came across this a while ago but can't now find it, I don't think
| I imagined it!
| 
| Anyway, is it possible to create a BGP import policy statement that will
| only accept prefixes from the advertising AS without having to specify
| the AS number?  I.e. can I create a policy statement that is generic that
| I can apply to a bunch of peers without having to create a specific one
| for each peer?

i'd implement that the following way:

protocols {
    bgp {
        group private-peer-xyz {
            import peer_routes_only;
            peer-as 65535;
            neighbor 192.168.1.1;
        }
    }
}

policy-options {
    policy-statement peer_routes_only {
        term 1 {
            from {
                protocol bgp;
                as-path any_AS_and_prepend;
            }
            then accept;
        }
        term last {
            then reject;
        }
    }
    as-path any_AS_and_prepend .+;
}

---
explanation: the wildcard . plus the + operator means:
  any single element in the AS_PATH or
  repetitions of that single element;


---

HTH,

/hannes


More information about the juniper-nsp mailing list