Skip to content

MetalLB with BGP configuration and Mikrotik router

elraro edited this page Jul 7, 2023 · 6 revisions

For a basic BGP configuration, you need the following:

  • A Mikrotik router RouterOS 7 (well, this guide is for this devices, so...).
  • The router's AS number (please, use a private number for the AS number).
  • The MetalLB's AS number (same).
  • The IP address range in CIDR format.

As an example, my configuration:

---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: metallb
  namespace: metallb-system
spec:
  interval: 5m
  chart:
    spec:
      chart: metallb
      version: 0.13.10
      sourceRef:
        kind: HelmRepository
        name: metallb-charts
        namespace: flux-system
  install:
    createNamespace: true
    remediation:
      retries: 3
  upgrade:
    remediation:
      retries: 3
  values:
    crds:
      enabled: true
apiVersion: metallb.io/v1beta1
kind: BGPAdvertisement
metadata:
  name: advertisement
  namespace: metallb-system
spec:
  ipAddressPools:
    - homepool
    - workpool
  peers:
    - peer
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
  name: homepool
  namespace: metallb-system
spec:
  autoAssign: false
  addresses:
    - "${METALLB_RANGE_HOME}"
apiVersion: metallb.io/v1beta2
kind: BGPPeer
metadata:
  name: peer
  namespace: metallb-system
spec:
  myASN: 65533
  peerASN: 65534
  peerAddress: 192.168.202.1

You can find more details here: https://github.com/elraro/home-ops/tree/main/cluster/core/metallb-system

The peer-address is the IP address of your Mikrotik router. I have used as peer-asn 65534 and for my-asn 65533.

To create a new BGP Connection in Mikrotik, open WinBox > Routing > BGP > Tab Connection > New

imagen

AS must be the peerASN. Also the Remote Address must be your IPAddressPool

Check if the BGP is working in Sessions tab.

imagen

Clone this wiki locally