Hi,
You can define you import policy as below.
policy-statement bgp-import {
term reject_6501_origin {
from as-path orig_6501;
then reject;
}
term peer_routes {
from as-path from_6504;
then accept;
}
term other_routes {
then reject;
}
}
as-path orig_6501 ".* 6501";
as-path from_6504 "6504 .*";
term other_routes ===== would reject all other routes which are not coming from 6504 or don't have 6504 at the begining of AS path
The term "other_routes" is inline to your requirement "I want to match the routes coming from 6504 AS in such a manner that only routes beyond 6504 should be accepted".
This is only to match your specified requirement on slecting the routes based on AS path.
Please ensure to modify the policy to meet other requirements, if any.
Hope this helps
If you liked this, Kudos would be appreciated.
Regards
Surya Prakash