Community discussions

MikroTik App
 
hci
Long time Member
Long time Member
Topic Author
Posts: 674
Joined: Fri May 28, 2004 5:10 pm

Prepend vs. Local Pref

Fri Oct 14, 2011 2:51 am

Say you have two peers and you want to prefer one over the other. The one you want to use the least you prepend like 3 on its out going filter. On the one you want to prefer you set local preference to about 300 on its incoming filter. Does this sound about right?
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Prepend vs. Local Pref

Fri Oct 14, 2011 5:14 am

Local preference is for setting policy with iBGP peers. For a single router it'd be simpler to set inbound weight. It gets evaluated first. Local preference would work, though. Yes on outbound padding.
 
mhosts
newbie
Posts: 36
Joined: Tue Nov 03, 2009 4:43 pm

Re: Prepend vs. Local Pref

Fri Oct 14, 2011 6:35 am

You would need to use both techniques.

Prepending your AS on the outgoing filters makes it less preferrable for other ISP's to send traffic through that particular link because you're "tricking" them into thinking that there is more AS's in the way. Since BGP uses the least amount of AS's to cross in calculating it's best route, most of the time you can control incoming traffic with this method. I say most of the time, because there are a lot of networks out there that strip out an AS that is prepended many times to be efficient with their routing.

As for using local pref, or bgp weights. This is to to give a preference on outgoing routes. Ones with higher weights will be preferred over those with less weight.

So, in order to use a particular link (say 1 out of 2) more often. You would need to use both methods to reduce the amount of traffic on a given link.
 
hci
Long time Member
Long time Member
Topic Author
Posts: 674
Joined: Fri May 28, 2004 5:10 pm

Re: Prepend vs. Local Pref

Fri Oct 14, 2011 5:54 pm

If I prepend at 3 would a local preference of 300 be a good match? I heard somewhere that local preference defaults at 100 if not specified so maybe 400 would be better?
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Prepend vs. Local Pref

Fri Oct 14, 2011 6:24 pm

The weight or local preference and prepending have nothing to do with one another. There's no 'match' to go for.

The default local preference is indeed 100. Setting it to 101 would be enough, because highest local preference wins, and 101 is larger than 100. 300 would work. 400 would work. 1000 would work. 99 wouldn't work. Doesn't matter as long as it's more than the default of 100.

I'd just set weight instead of local preference. Weight defaults to 0, so setting any weight will ALWAYS work, even if MT decides tomorrow to default the local pref to 500, so your 101, 300, or 400 don't cut it anymore. You don't gain anything by using local preference over weight, and weight gets compared first. So using weight makes things easier for your router as it has to compare fewer things for every route it has to evaluate.
 
hci
Long time Member
Long time Member
Topic Author
Posts: 674
Joined: Fri May 28, 2004 5:10 pm

Re: Prepend vs. Local Pref

Fri Oct 14, 2011 6:25 pm

Also, when you make changes to your BGP filters do they take affect immediately or only on new incoming or outgoing routes?
 
hci
Long time Member
Long time Member
Topic Author
Posts: 674
Joined: Fri May 28, 2004 5:10 pm

Re: Prepend vs. Local Pref

Fri Oct 14, 2011 6:34 pm

I still want to use both out bound routes but only use the secondary when its way shorter.
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Prepend vs. Local Pref

Fri Oct 14, 2011 7:02 pm

It would be much easier to help you if you didn't keep shifting the goal posts. You keep adding conditions to your questions that entirely change the answers.

For what you're asking for now you can't use weight or local preference, because it'll be applied to ALL routes from a peer- unless you're planning on processing every prefix you receive and set weight/local preference on them manually based on their AS path length. Which would be a very bad idea and completely unfeasible if you're running full routing tables. One exception could be where you want to manually identify just a few dozen paths to use the worse peer for, but it wouldn't dynamically pick the second peer if it's "much better". BGP doesn't work that way.

You could do inbound prepending to prepend the your own AS or the peer AS two or three times on the less preferable peer on inbound routing prefixes. That would make most paths longer than anything you get from the better peer, except for paths where the worse peer is already 2 or 3 times shorter than the better peer. Many people consider inbound prepending to be something you wouldn't want to do outside a lab, but for a simple network with just one router that doesn't act as a transit AS I guess it could work OK.
 
hci
Long time Member
Long time Member
Topic Author
Posts: 674
Joined: Fri May 28, 2004 5:10 pm

Re: Prepend vs. Local Pref

Fri Oct 14, 2011 7:15 pm

Simple problem.

Peer1 -> 100mbps burstable
Peer2 -> 1gbps flat rate

I want most in bound and out bound traffic to use Peer2.

I still want Peer1 used for both incoming and outgoing when peer2 has a very long route or no route.

Think that sums it up. I am thinking the inbound traffic is likely easy to solve with prepending. The outbound not so simple I am guessing.

I imagine there is also a way with routing marks to force all traffic out the port it came in. Then I imagine I would only need to use prepending.
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Prepend vs. Local Pref

Fri Oct 14, 2011 7:17 pm

You could do inbound prepending to prepend the your own AS or the peer AS two or three times on the less preferable peer on inbound routing prefixes. That would make most paths longer than anything you get from the better peer, except for paths where the worse peer is already 2 or 3 times shorter than the better peer. Many people consider inbound prepending to be something you wouldn't want to do outside a lab, but for a simple network with just one router that doesn't act as a transit AS I guess it could work OK.
Prepend both inbound and outbound to make decisions solely based on AS path length. Of course peer 1 would be used if peer 2 doesn't have a route to a specific destination. If there's only one route, it'll be used.
 
hci
Long time Member
Long time Member
Topic Author
Posts: 674
Joined: Fri May 28, 2004 5:10 pm

Re: Prepend vs. Local Pref

Fri Oct 14, 2011 7:21 pm

I thought you could only prepend when advertising to your peers. I did not thinking you could prepend the incoming routes coming from them? If I can thats exactly what I need to do.
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Prepend vs. Local Pref

Fri Oct 14, 2011 7:36 pm

http://wiki.mikrotik.com/wiki/Manual:Ro ... Properties
set-bgp-prepend (integer: 0..16 | default;) how many times to prepend router's own AS number to AS_PATH attribute
For incoming filters, it affects the AS_PATH attribute length, which is used in BGP route selection process. For outgoing filters, the prepending is done when announcing route via BGP and affects only routes sent to EBGP peers (for IBGP value 1 is always used)
If value is set to 0 then peer's own AS is removed from AS_PATH (Similar to CISCO feature "no bgp enforce-first-as")

set-bgp-prepend-path (AS list;) add specified list of AS numbers to AS_PATH attribute
If both set-bgp-prepend and set-bgp-prepend-path are used then set-bgp-prepend will have highest priority.
 
hci
Long time Member
Long time Member
Topic Author
Posts: 674
Joined: Fri May 28, 2004 5:10 pm

Re: Prepend vs. Local Pref

Fri Oct 14, 2011 7:44 pm

Thanks.

Who is online

Users browsing this forum: bcmdevtl and 23 guests