My router got the same prefixe of the same ASN via eBGP from different sites. And transfers these routes via iBGP on my backbone.
For example, I learned google's routes from Japan and Hong Kong. But I wish some of my pops chose Google routes from Hong Kong, others chose from Japan.
How could I reach this goal ? BGP metric 2 ?
If you don't want to take IGP metric into account then the easiest way is probably to add communities (via import policy on your eBGP neighbors) and then use those communities differently in iBGP import policy on your other routers.
I am just thinking can I use bgp's attribute - metric2 to control it ?
Because there are the same igp metric and local preference for google routes learning from Hong Kong and Japan.
So, I need metric2 or metric to force more shorter distance's routes or path having higher priority.
Is it possbile to get the goal ? Mean that choses by prefixes or community for defferent pops.
metric is the MED value and metric2 is IGP metric so that is not going to help you with your scenario. You need to use communities and local-preference as other people who have responded are suggesting. It would be something like this:
As you guys sad, I have to use community string and local preference to match my purpose.
But I still have one question. What is function of bgp metric - metric4 ?
Since I saw it , but why can't use it ?
# set policy-options policy-statement AS16059-IN termAS16059-IN then ?
> metric Metric value> metric2 Metric value 2> metric3 Metric value 3> metric4 Metric value 4
They are not BGP attributes. The only one of those 4 metrics that you are seeing under the policy configuration, that applies to BGP, is metric (which is the MED).