Dual ISP bgp on Mikrotik with load-balancing and automatic failover.
I have two unequal connections to the internet with a prefix of 192.168.40.0/24 that I need to advertise to the internet via the two ISPs. Why would I want to do this? To make sure that my prefix is reachable via the two ISPs and that my network stays up as long as one of the ISPs is active.
Objective:
HQ-ROUTER:
ISP1-ROUTER:
ISP2-ROUTER:
Configuration
BGP setup
[[email protected]] > routing filter add chain=ABC-OUT prefix=192.168.40.0/24 set-bgp-prepend path=400,400
[[email protected]] > routing bgp instance add as=400 name=default client-to-client -reflection=yes
( Note that a router cannot be a member of more than one AS)
[[email protected]] > routing bgp peer add name=peer1 instance=default remote-addre ss=4.4.4.2 remote-as=200 update-source=ether4(this establishes the neighbor relationshipwith ISP1).
[[email protected]] > routing bgp peer add name=peer2 instance=default remote-addre ss=5.5.5.2 remote-as=300 update-source=ether5 set out-filter=ABC-OUT
On ISP1 router:
[[email protected]] > ip address add address=4.4.4.2/30 interface=ether4
Create a bridge
[[email protected]] > interface bridge add name=bridge1
Assign an IP to the bridge.
[[email protected]] > ip address add address=10.0.0.1/24 interface=bridge1 ( you can use anyinterface as your LAN instead of the bridge.)
Enable BGP and assign AS number to 200 to the router.
[[email protected]] > routing bgp instance add as=200 name=default client-to-client
Peer with HQ router
[[email protected]] > routing bgp peer add name=peer1 instance=default remote-address=4.4.4.1 remote-as=400 update-source=ether4( as an ISP, you can also implement a filterrule to allow only the public prefix of a client into the routing table of ISP1 router. We will do that on ISP2)
On ISP2:
Assign an IP to the interface connecting HQ
[[email protected]] > ip address add address=5.5.5.2/30 interface=ether5
Create a bridge
[[email protected]]> interface bridge add name=bridge1
Assign an IP to the bridge.
[[email protected]] > ip address add address=20.0.0.1/24 interface=bridge1 ( you can use any interface as your LAN instead of the bridge.)
Create a filter rule to accept only the prefix on HQ router. This will make sure that ISP2 does not receive the prefixes from any other router. This feature is used to save the router from having the entire routing table of the internet dumped on it.
[[email protected]] > routing filter add chain=ABC-IN prefix=192.168.40.0/24 invert-match=yes action=discard
Enable BGP and assign AS number to 300 to the router.
Peer with HQ router while making sure that only the prefix of HQ is allowed in.
[[email protected]] > routing bgp peer add name=peer1 instance=default remote-addre ss=5.5.5.1 remote-as=400 update-source=ether5 set in-filter=ABC-IN
– disabled, E – established
INSTANCE REMOTE-ADDRESS REMOTE-AS
ISP1 routing table has entries for HQ’s prefix and the prefix of ISP2. Now, let’s see how many AS it will take to get to HQ from ISP1. To see that double-click on the HQ entry in the routing table and click on attributes.
You may also like: Basic ebgp setup on Cisco router
Because of the filter rule, ISP2 has no entry for the prefix attached to ISP1(10.0.0.0/24). This is a good way of not only making sure that clients do not goof up your routing table but also saving your router’s processor. Now let’ts see how many AS it takes to get to HQ from ISP2. Remember we used AS-PATH-PREPEND for that peering with ISP2. Let’s see if it worked.
I see you don’t monetize your site, don’t waste your traffic, you
can earn extra cash every month because you’ve got high quality content.
If you want to know how to make extra $$$, search for: Ercannou’s essential adsense alternative
Thanks for the advice. I will look into it.