Community discussions

MikroTik App
 
hidagar
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 65
Joined: Wed Mar 04, 2009 5:45 pm

BGP with 2 Peer

Wed Jun 26, 2013 1:31 pm

Hello,

I setup the BGP Full Routing with my ISP. They provaide me 2 Peer, 1 for backup. They say me that I should add this rules to discrimine the Main PEER and the Backup PEER.

0 chain=BACK_TEL_OUT bgp-med=200 invert-match=no action=passthrough
set-bgp-prepend-path=""

1 chain=BACK_TEL_IN bgp-local-pref=50 invert-match=no action=passthrough
set-bgp-prepend-path=""

2 chain=PRIN_TEL_IN bgp-local-pref=100 invert-match=no action=passthrough
set-bgp-prepend-path=""

3 chain=PRIN_TEL_OUT bgp-med=100 invert-match=no action=passthrough
set-bgp-prepend-path=""


But the Route table say that always going from Backup PEER, and the Main one is in backup.

It's the rules bad?

Thanks
 
szastan
newbie
Posts: 35
Joined: Sat Aug 06, 2011 7:44 pm
Location: Gdansk, Poland
Contact:

Re: BGP with 2 Peer

Fri Jun 28, 2013 9:29 pm

hey, try to set local preference in your out filters (higher is preferable) and see if your outgoing traffic pass with primary connection
 
zakai
newbie
Posts: 26
Joined: Thu Apr 18, 2013 4:04 pm

Re: BGP with 2 Peer

Tue Jul 02, 2013 2:10 pm

Hi hidagar,

what you'd want to do is something similar to this:

ros code

/routing filter
add action=accept chain=isp-out-main comment="your advertised network through main seesion" prefix=1.2.3.0/24
add action=discard chain=isp-out-main comment="discard the rest"

add action=accept chain=isp-out-back comment="your advertised network through backup" prefix=1.2.3.0/24 set-bgp-prepend=3
add action=discard chain=isp-out-back comment="discard the rest"

add action=accept chain=isp-in-main set-bgp-local-pref=500 comment="accept all BGP routes from the main ISP session"
add action=accept chain=isp-in-back set-bgp-local-pref=100 comment="accept all BGP routes from the backup ISP session"
line 2,3: you accept your IP space to be advertised to the ISP through the main BGP session and discard everything else. Of course it depends on you what and how you want to advertise, this is just an example.

line 5,6: the same as 2,3 but you prepend your ASN 3 times. This way the incoming packets will take the route through your ISP's main session while this path will be just a backup in case the main one fails. Now there are different mechanisms you could use to influence the route selection for incoming packets, this is one way of doing it. A solution where you have total control over the route selection would be if you advertise smaller portions of you IP space through your main session and the entire block through the backup session. This way, the most specific route (i.e. the ones advertised as smaller networks) will win.

line 8: all the routes coming through your main session will have a local pref of 500.
line 9: all the routes coming through the backup session will have a local pref of 100. This way, all the outgoing packets (leaving your ASN) will use the routes from the main session (the higher the local preference, the higher the preference in selecting that route)

The final step would be to add the routing filters to your sessions, as follow:
- for the main session set the in-filter=isp-in-main, out-filter=isp-out-main
- for the backup session set the in-filter=isp-in-back, out-filter=isp-out-back

Hope this helps!

[EDIT] lines 8,9: set-bgp-local-pref instead of bgp-local-pref
 
hidagar
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 65
Joined: Wed Mar 04, 2009 5:45 pm

Re: BGP with 2 Peer

Fri Jul 05, 2013 10:34 am

Hello,

Thanks for the help.

I should accept my networks then with the filters? In Cisco I can set only Local-Pref and MED. I'm new in BGP sessions with mikrotik and it's a bit diferent.

My networks it's working properly but I stilling have the problem, then I will try to accept the networks.

Thanks
 
zakai
newbie
Posts: 26
Joined: Thu Apr 18, 2013 4:04 pm

Re: BGP with 2 Peer

Mon Jul 08, 2013 2:16 pm

Hi hidagar,

while the previous commands are issued under /ip route filter and define the input and output filters for both main and backup sessions, you'll have to apply these filters to the BGP sessions.

The following is an example of adding two peers, one responsible for the main session and one for the backup, and attaching the previously created filters in relation to my previous post:

ros code

/routing bgp peer
add name="isp-main" instance=default remote-address=1.2.3.1 remote-as=1234 in-filter=isp-in-main out-filter=isp-out-main comment="ISP peer for main session"
add name="isp-back" instance=default remote-address=1.2.3.5 remote-as=1234 in-filter=isp-in-back out-filter=isp-out-back comment="ISP peer for backup session"
Note that these lines will add the peers and attach the filters. If you have the peers configured already you could do an edit. I suggest you do a 'clean' add and test the setup.

Hope this helps!
 
User avatar
StubArea51
Trainer
Trainer
Posts: 1739
Joined: Fri Aug 10, 2012 6:46 am
Location: stubarea51.net
Contact:

Re: BGP with 2 Peer

Tue Jul 09, 2013 3:48 am

It depends on what direction you want to influence traffic...

To prefer a link for inbound traffic use:

- AS Path Prepending
- Multi Exit Discriminator (MED) aka BGP "Metric"

To prefer a link for outbound traffic use:

- Local Preference
- Weight
- Next Hop

One of the best way to manage traffic is to find out what communities your provider uses (assuming this is a public peering) and tag routes with that community. I alway use communities over prepending when available as it is a much cleaner way of selecting traffic. take a look

http://evilrouters.net/2009/03/18/using ... e-routing/

Who is online

Users browsing this forum: No registered users and 21 guests