Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VRRP: Add keepalived #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion vrrp/frr/rt-1.conf → vrrp/frr/rt1.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
hostname rt-1
hostname rt1
!
interface eth-br1
vrrp 51 version 2
Expand Down
2 changes: 1 addition & 1 deletion vrrp/frr/rt-2.conf → vrrp/frr/rt2.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
hostname rt-2
hostname rt2
!
interface eth-br1
vrrp 51 version 2
Expand Down
1 change: 1 addition & 0 deletions vrrp/holo/rt-1.conf → vrrp/holo/rt1.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
interfaces interface eth-br1
type iana-if-type:ethernetCsmacd
ipv4
ipv4 address 10.0.1.1 prefix-length 24
!
ipv4 vrrp vrrp-instance 51
priority 10
Expand Down
1 change: 1 addition & 0 deletions vrrp/holo/rt-2.conf → vrrp/holo/rt2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
interfaces interface eth-br1
type iana-if-type:ethernetCsmacd
ipv4
ipv4 address 10.0.1.2 prefix-length 24
!
ipv4 vrrp vrrp-instance 51
priority 20
Expand Down
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions vrrp/keepalived/.topo.yml.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: vrrp-keepalived


topology:
nodes:
rt1:
kind: linux
image: ubuntu:24.04
binds:
- mine.sh:/kd.sh
- rt1.conf:/etc/keepalived/keepalived.conf
exec:
- "/kd.sh"
10 changes: 10 additions & 0 deletions vrrp/keepalived/rt1.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
vrrp_instance VI_1 {
interface eth-br1
priority 10
use_vmac
virtual_router_id 51
advert_int 1
virtual_ipaddress {
10.0.1.5
}
}
16 changes: 16 additions & 0 deletions vrrp/keepalived/rt1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

if command -v /usr/sbin/keepalived; then
# Setup interfaces

# loopback
ip addr add 1.1.1.1/32 dev lo
ip link set lo up

# eth-br1
ip addr add 10.0.1.1/24 dev eth-br1
ip link set eth-br1 up


service keepalived start
fi
10 changes: 10 additions & 0 deletions vrrp/keepalived/rt2.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
vrrp_instance VI_1 {
interface eth-br1
priority 20
use_vmac
virtual_router_id 51
advert_int 1
virtual_ipaddress {
10.0.1.5
}
}
16 changes: 16 additions & 0 deletions vrrp/keepalived/rt2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

if command -v /usr/sbin/keepalived; then
# Setup interfaces

# loopback
ip addr add 2.2.2.2/32 dev lo
ip link set lo up

# eth-br1
ip addr add 10.0.1.2/24 dev eth-br1
ip link set eth-br1 up


service keepalived start
fi
13 changes: 13 additions & 0 deletions vrrp/keepalived/topo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: vrrp-keepalived


topology:
nodes:
rt1:
kind: linux
image: ubuntu:24.04
binds:
- mine.sh:/kd.sh
- rt1.conf:/etc/keepalived/keepalived.conf
exec:
- "/kd.sh"
21 changes: 21 additions & 0 deletions vrrp/rare/rt1.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
!
vrf definition v1
rd 1:1
exit
interface loopback0
vrf forwarding v1
ipv4 address 2.2.2.2 255.255.255.255
no shutdown
no log-link-change
exit
interface ethernet1
vrf forwarding v1
ipv4 address 10.0.1.1 255.255.255.0
ipv4 vrrp address 10.0.1.5
ipv4 vrrp version 2
ipv4 vrrp group 51
ipv4 vrrp priority 10
no shutdown
no log-link-change
exit
!
21 changes: 21 additions & 0 deletions vrrp/rare/rt2.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
!
vrf definition v1
rd 1:1
exit
interface loopback0
vrf forwarding v1
ipv4 address 2.2.2.2 255.255.255.255
no shutdown
no log-link-change
exit
interface ethernet1
vrf forwarding v1
ipv4 address 10.0.1.2 255.255.255.0
ipv4 vrrp address 10.0.1.5
ipv4 vrrp version 2
ipv4 vrrp group 51
ipv4 vrrp priority 20
no shutdown
no log-link-change
exit
!
77 changes: 61 additions & 16 deletions vrrp/topology.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# | 10.0.1.1/24 | 10.0.1.2/24
# +-------------+ +----------+ +------------+
# | | | | | |
# | RT-1 | | Virtual | | RT-2 |
# | RT1 | | Virtual | | RT2 |
# | 1.1.1.1 |==============| Router |=============| 2.2.2.2 |
# | | | 10.0.1.5| | |
# +-------------+ +----------+ +------------+
Expand All @@ -34,6 +34,7 @@
name: vrrp

topology:

defaults:
binds:
- ../scripts/start.sh:/start.sh
Expand All @@ -43,42 +44,86 @@ topology:
- "/start.sh"
- "/frr-setup.sh"

nodes:

kinds:
rare:
image: ghcr.io/rare-freertr/freertr-containerlab:latest

nodes:
br1:
kind: bridge

rt-1:
kind: linux
rt1:

# ---- holod image ----
kind: linux
image: ghcr.io/holo-routing/holo:latest

# ---- frr image ----
# kind: linux
# image: quay.io/frrouting/frr:9.0.2

# ---- RARE/free-rtr image ----
# kind: rare
# NOTE: If 'kind:rare' is enabled, look through the links
# to understand how to configure.

# ---- keepalived image ----
# kind: linux
# image: ghcr.io/paul-weqe/keepalived:latest

binds:
- interfaces/rt-1:/etc/network/interfaces
- holo/rt-1.conf:/etc/holo.startup
- frr/rt-1.conf:/etc/frr/frr.startup
- interfaces/rt1:/etc/network/interfaces
- holo/rt1.conf:/etc/holo.startup
- frr/rt1.conf:/etc/frr/frr.startup
- rare/rt1.conf:/rtr/run/conf/rtr-sw.txt
- keepalived/rt1.conf:/etc/keepalived/keepalived.conf
- keepalived/rt1.sh:/kd.sh

rt-2:
kind: linux
exec:
- "/kd.sh"

rt2:
# ---- holod image ----
kind: linux
image: ghcr.io/holo-routing/holo:latest

# ---- frr image ----
# kind: linux
# image: quay.io/frrouting/frr:9.0.2

# ---- RARE/free-rtr image ---
# kind: rare
# NOTE: If 'kind:rare' is enabled, look through the links
# to understand how to configure.

# ---- keepalived image ----
# kind: linux
# image: ghcr.io/paul-weqe/keepalived:latest

binds:
- interfaces/rt-2:/etc/network/interfaces
- holo/rt-2.conf:/etc/holo.startup
- frr/rt-2.conf:/etc/frr/frr.startup
- interfaces/rt2:/etc/network/interfaces
- holo/rt2.conf:/etc/holo.startup
- frr/rt2.conf:/etc/frr/frr.startup
- rare/rt2.conf:/root/router.startup
- keepalived/rt2.conf:/etc/keepalived/keepalived.conf
- keepalived/rt2.sh:/kd.sh

exec:
- "/kd.sh"

links:
# 10.0.1.0/24
# Due to clab's RARE/freertr naming conventions,
# interfaces may need to be customized to run RARE.
- endpoints: ["host:br-host", "br1:eth-h1"]
- endpoints: ["rt-1:eth-br1", "br1:eth-rt1"]
- endpoints: ["rt-2:eth-br1", "br1:eth-rt2"]

# If rt1 is frr/holo
- endpoints: ["rt1:eth-br1", "br1:eth-rt1"]
# If rt1 is RARE/free-rtr
# - endpoints: ["rt1:eth1", "br1:eth-rt1"]

# If rt2 is frr/holo
- endpoints: ["rt2:eth-br1", "br1:eth-rt2"]
# If rt2 is RARE/free-rtr
# - endpoints: ["rt2:eth2", "br1:eth-rt2"]