BGP Traffic Manipulation

It was supposed to do the job, but it seemed not.

Two BGP peers with full routing table on one router CCR1036.

Purpose: Peer1 is preferable path for incoming and outgoing traffic.
Peer2 is less preferable.

I have tried to set AS Prepend on Peer2 to make Rx (incoming traffic) less preferable path. However, no matter what AS Prepend number I tried, 5, 10, and 15, it seems no difference. Rx is still more than Rx on Peer1.

Notes: after the filter modified, I did run /routing BGP peer refresh (peername).
The upstream did see more my AS numbers.

Second, I tried to set either Weight or Local Preference higher on Peer1 for sending traffic preferable path, seems less effects either.

Questions:

In order to receive full routing table, what is a correct in-filter?

Prefix 0.0.0.0/0 without prefix length accept
Prefix 0.0.0.0/0 with prefix length 0 accept

which one is correct? or something else?

Set Weight or Set Local Preference in which filter, in-filter or out-filter?

I think I was on right track, but it seemed not working.

Really appreciate it if you could help.

Shawn

Hello

I have tried to set AS Prepend on Peer2 to make Rx (incoming traffic) less preferable path. However, no matter what AS Prepend number I tried, 5, 10, and 15, it seems no difference. Rx is still more than Rx on Peer1.

Notes: after the filter modified, I did run /routing BGP peer refresh (peername).
The upstream did see more my AS numbers.

Even if prepend is working correctly, you have little control on how people send traffic to your AS.
They can override your prepend with their weight/local-pref. It is also possible that the people sending traffic to you only have peer2 as upstream.


In order to receive full routing table, what is a correct in-filter?

If you want to receive every prefix that your peer advertises, than do not use a filter or do not set any prefix related parameters in the filter.
You might want to deny some prefixes to protect your network from misconfigurations though (eg: filter martians/bogons networks, your own IP ranges, etc.).

Set Weight or Set Local Preference in which filter, in-filter or out-filter?

Weight and local preference are set when you receive routes from a peer, so it is defined in an in-filter.
For example:

/routing bgp peer
add in-filter=peer1-in name=peer1 remote-address=10.0.0.1 remote-as=100
/routing filter
add chain=peer1-in set-bgp-local-pref=200

[admin@MikroTik] /routing> /ip route print detail
Flags: X - disabled, A - active, D - dynamic, C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme, B - blackhole, U - unreachable, P - prohibit
 0 ADC  dst-address=10.0.0.0/24 pref-src=10.0.0.2 gateway=ether3 gateway-status=ether3 reachable distance=0 scope=10

 1 ADb  dst-address=192.168.2.0/24 gateway=10.0.0.1 gateway-status=10.0.0.1 reachable via  ether3 distance=20 scope=40 target-scope=10 bgp-as-path="100" bgp-local-pref=200 bgp-med=0 bgp-origin=igp received-from=peer1

 2 ADb  dst-address=192.168.87.0/24 gateway=10.0.0.1 gateway-status=10.0.0.1 reachable via  ether3 distance=20 scope=40 target-scope=10 bgp-as-path="100" bgp-local-pref=200 bgp-med=0 bgp-origin=igp received-from=peer1

 3 ADb  dst-address=192.168.122.0/24 gateway=10.0.0.1 gateway-status=10.0.0.1 reachable via  ether3 distance=20 scope=40 target-scope=10 bgp-as-path="100" bgp-local-pref=200 bgp-med=0 bgp-origin=igp received-from=peer1

Weight and local-pref work the same way: routes with highest values are preferred.
However, weight is only local to the router. Local-pref is advertised to your iBGP peers.

Instead of Prepends you can use MED (Multi Exit Discrimator) to control incoming traffic - if your rest of your configuration allows for it.

In this talk he describes the use of MED on slides 26-28
http://mum.mikrotik.com/presentations/GR15/MUMGreece-Athens-2015-Nikalexis_Nikos.pdf

Useful info
http://wiki.mikrotik.com/wiki/Manual:BGP_Best_Path_Selection_Algorithm
http://wiki.mikrotik.com/wiki/Manual:Routing/BGP

Thank you very much, Tirkitneth, for your more clear concept.

I will remove the prefix 0.0.0.0/0 and prefix length 0 in in-filter, and set weight or local preference to try.

Thanks, Cha0s, another way to do it.