Commit 14a39d7b authored by glucas's avatar glucas

Add ucarp scripts and systemd unit.

parent 575a060b
For explanations, use-case presentation and how-to use, see https://wiki.arn-fai.net/technique:carp (in french, sorry).
# Copyright (C) 2015-2016 Alsace Réseau Neutre
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Debian GNU/Linux: store this in /etc/systemd/system/
[Unit]
Description=ucarp daemon.
After=syslog.target network.target
[Service]
Type=simple
ExecStart=/usr/sbin/ucarp -z -i h-carpcontrol -s 169.254.43.254 -v 1 -p password_here -a 169.254.43.1 -x fe80::43:1 -k 100 -n -u /etc/carp/vip-up.sh -d /etc/carp/vip-down.sh
[Install]
WantedBy=multi-user.target
# Copyright (C) 2015-2016 Alsace Réseau Neutre
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Debian GNU/Linux: store this in /etc/systemd/system/
[Unit]
Description=ucarp daemon.
After=syslog.target network.target
[Service]
Type=simple
ExecStart=/usr/sbin/ucarp -z -i h-carpcontrol -s 169.254.43.253 -v 1 -p password_here -a 169.254.43.1 -x fe80::43:1 -P -k 1 -n -u /etc/carp/vip-up.sh -d /etc/carp/vip-down.sh
[Install]
WantedBy=multi-user.target
#!/bin/sh
# Copyright (C) 2015-2016 Alsace Réseau Neutre
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Debian GNU/Linux: store this where you want. For example: /etc/carp/
IPBIN="/sbin/ip"
VLANIDREGEX="5[0-9]{2}"
CARPIF=$1
VIPv4=$2
VIPv6=$3
IFLIST=$($IPBIN -d l | grep -B2 -E "802.1Q id $VLANIDREGEX" | grep -Po "h-[a-z]+(?=@)")
for iface in $IFLIST
do
echo "[INFO] Deleting VIP $VIPv4 from interface $iface"
$IPBIN a d $VIPv4/24 scope link dev $iface
echo "[INFO] Deleting VIP $VIPv6 from interface $iface"
$IPBIN -6 a d $VIPv6/112 scope link dev $iface
done
#!/bin/sh
# Copyright (C) 2015-2016 Alsace Réseau Neutre
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Debian GNU/Linux: store this where you want. For example: /etc/carp/
IPBIN="/sbin/ip"
ARPPINGBIN="/usr/bin/arping"
FAKEADVBIN="/usr/bin/atk6-fake_advertise6"
VLANIDREGEX="5[0-9]{2}"
CARPIF=$1
VIPv4=$2
VIPv6=$3
IFLIST=$($IPBIN -d l | grep -B2 -E "802.1Q id $VLANIDREGEX" | grep -Po "h-[a-z]+(?=@)")
if [ ! -x $ARPPINGBIN ] || [ ! -x $FAKEADVBIN ]; then
echo "[ERROR] $ARPPINGBIN or $FAKEADVBIN not installed or not executable!"
exit 1
fi
for iface in $IFLIST
do
echo "[INFO] Adding VIP $VIPv4 on interface $iface"
$IPBIN a a $VIPv4/24 scope link dev $iface
echo "[INFO] Flooding gratuitous ARP for VIP $VIPv4 on interface $iface"
$ARPPINGBIN -I $iface -c 10 -q -U $VIPv4 1>/dev/null &
echo "[INFO] Adding VIP $VIPv6 on interface $iface"
$IPBIN -6 a a $VIPv6/112 scope link dev $iface
echo "[INFO] Flooding unsolicited NDP advertisement for VIP $VIPv6 on interface $iface"
$FAKEADVBIN -n 10 -w 1 $iface $VIPv6 1>/dev/null &
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment