Skip to content

Instantly share code, notes, and snippets.

@jamcole
Last active August 12, 2020 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamcole/c64a023780f2d99852b0bafed6bc6a31 to your computer and use it in GitHub Desktop.
Save jamcole/c64a023780f2d99852b0bafed6bc6a31 to your computer and use it in GitHub Desktop.
keepalived ocp vrrp unicast poc
#!/bin/sh
if [ $(ss -nlt4H '( sport = :8443 )'|wc -c) -eq 0 ]; then exit 1; fi
#!/bin/sh
/usr/bin/ping -c 1 -W 5 $( ip -4 route get 1.1.1.1|head -n 1|awk '{print $3}')
exit $?
#!/bin/sh
if [ $(ss -nlt4H '( sport = :80 )'|wc -c) -eq 0 ]; then exit 1; fi
! Configuration File for keepalived
global_defs {
vrrp_skip_check_adv_addr
vrrp_garp_interval 0
vrrp_gna_interval 0
enable_script_security
script_user root root
init_fail
}
vrrp_script chk_masters {
script "/etc/keepalived/chk_masters"
interval 2 # check every 2 seconds
weight -4
}
vrrp_script chk_routers {
script "/etc/keepalived/chk_routers"
interval 2 # check every 2 seconds
weight -4
}
vrrp_script chk_nexthop {
script "/etc/keepalived/chk_nexthop"
interval 10
weight -4
}
vrrp_instance VI_1 {
state MASTER
interface enp0s8.21
virtual_router_id 51
priority 101
advert_int 1
track_interface {
enp0s9
}
authentication {
auth_type PASS
auth_pass CHANGEME2
}
virtual_ipaddress {
70.99.204.45/23 dev enp0s9
172.21.255.1/16 dev enp0s8.21
}
track_script {
chk_masters
chk_routers
}
unicast_src_ip 172.21.10.2
unicast_peer {
172.21.10.1
172.21.10.3
}
}
vrrp_instance VI_2 {
state MASTER
interface enp0s8.21
virtual_router_id 52
priority 103
advert_int 1
track_interface {
enp0s9
}
authentication {
auth_type PASS
auth_pass CHANGEME
}
virtual_ipaddress {
172.21.255.254/16 dev enp0s8.21
}
track_script {
chk_nexthop
}
unicast_src_ip 172.21.10.1
unicast_peer {
172.21.10.2
172.21.10.3
}
}
! Configuration File for keepalived
global_defs {
vrrp_skip_check_adv_addr
vrrp_garp_interval 0
vrrp_gna_interval 0
enable_script_security
script_user root root
init_fail
}
vrrp_script chk_masters {
script "/etc/keepalived/chk_masters"
interval 2 # check every 2 seconds
weight -4
}
vrrp_script chk_routers {
script "/etc/keepalived/chk_routers"
interval 2 # check every 2 seconds
weight -4
}
vrrp_script chk_nexthop {
script "/etc/keepalived/chk_nexthop"
interval 10
weight -4
}
vrrp_instance VI_1 {
state MASTER
interface enp0s8.21
virtual_router_id 51
priority 102
advert_int 1
track_interface {
enp0s9
}
authentication {
auth_type PASS
auth_pass CHANGEME2
}
virtual_ipaddress {
70.99.204.45/23 dev enp0s9
172.21.255.1/16 dev enp0s8.21
}
track_script {
chk_masters
chk_routers
}
unicast_src_ip 172.21.10.2
unicast_peer {
172.21.10.1
172.21.10.3
}
}
vrrp_instance VI_2 {
state MASTER
interface enp0s8.21
virtual_router_id 52
priority 102
advert_int 1
track_interface {
enp0s9
}
authentication {
auth_type PASS
auth_pass CHANGEME
}
virtual_ipaddress {
172.21.255.254/16 dev enp0s8.21
}
track_script {
chk_nexthop
}
unicast_src_ip 172.21.10.2
unicast_peer {
172.21.10.1
172.21.10.3
}
}
! Configuration File for keepalived
global_defs {
vrrp_skip_check_adv_addr
vrrp_garp_interval 0
vrrp_gna_interval 0
enable_script_security
script_user root root
init_fail
}
vrrp_script chk_masters {
script "/etc/keepalived/chk_masters"
interval 2 # check every 2 seconds
weight -4
}
vrrp_script chk_routers {
script "/etc/keepalived/chk_routers"
interval 2 # check every 2 seconds
weight -4
}
vrrp_script chk_nexthop {
script "/etc/keepalived/chk_nexthop"
interval 10
weight -4
}
vrrp_instance VI_1 {
state MASTER
interface enp0s8.21
virtual_router_id 51
priority 103
advert_int 1
track_interface {
enp0s9
}
authentication {
auth_type PASS
auth_pass CHANGEME2
}
virtual_ipaddress {
70.99.204.45/23 dev enp0s9
172.21.255.1/16 dev enp0s8.21
}
track_script {
chk_masters
chk_routers
}
unicast_src_ip 172.21.10.3
unicast_peer {
172.21.10.1
172.21.10.2
}
}
vrrp_instance VI_2 {
state MASTER
interface enp0s8.21
virtual_router_id 52
priority 101
advert_int 1
track_interface {
enp0s9
}
authentication {
auth_type PASS
auth_pass CHANGEME
}
virtual_ipaddress {
172.21.255.254/16 dev enp0s8.21
}
track_script {
chk_nexthop
}
unicast_src_ip 172.21.10.3
unicast_peer {
172.21.10.1
172.21.10.2
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment