why prepend not working?

Hello,
i have bgp session with cogent in 2 different country so i am announce same prefix from my primary router in location A then i establish ibgp with my ccr in location b and i am advertising x.x.x.x/24 in primary link with x5 prepend and announce it by ibgp to my location b with no prepend so my best path should be location B but my incoming traffic still choose location A, also i tried MED but it not working,
any idea how solve it?
thanks

Have you used any looking glass / public route servers to determine whether your AS-PREPEND is actually happening?

MEDs will only work if:
a) you have multiple links to the same carrier (apparently true for you)
b) the carrier has configured your peering sessions to accept MEDs from your network
c) your network originates the routes with different interior costs to reach the destination - i.e. the two links should show different costs on the carrier’s side.

yes when i disable my announced route in location B , lg.he.net show x5 prepend but when i enable it again it choose it choose wrong path,
any idea?

This is pretty normal. Your ISP is only going to forward its preferred path along to its other peers, so pretty much all of the Internet is only going to see the non-prepended path. Prepending is the way to balance separate carriers. It won’t work for a single carrier. (I don’t know why I didn’t think of this before making my previous post)

Now that I’ve thought about it - if you’re only announcing one prefix into the Internet via multiple links into the same carrier, then you’re never going to get load sharing because all traffic on the Internet must first reach your ISP. The only option is for your ISP to allow ECMP from BGP-learned routes from you. Any metric you advertise is only going to cause your ISP to prefer one link or the other. Since you have only one ISP, all traffic must go to that ISP first.

If you have multiple ISPs or multiple prefixes, then you can engineer traffic on your own.

One other possibility would be if your ISP allows you to send them longer prefixes than /24. If you can do that, then you could do something like this:
Suppose your IP block is 192.0.2.0/24
Announce 192.0.2.0/24 into both links
Announce 192.0.2.0/25 into link 1 and 192.0.2.128/25 into link 2. That would split traffic into your network based on which half of the /24 was the destination. The /24 prefix is there for two reasons:
1- prefixes longer than /24 are going to get filtered out of the global routing table
2- it acts as a backup route in case one of your links goes down.
– say link 2 were to go down. The 192.0.2.128/25 prefix would disappear from your ISP’s table. However, that space is covered by the 192.0.2.0/24 prefix that remains available on link 1, so all traffic would converge on link 1.

perfect answer my friend,
thank for help