Direct Server Return (DSR) am Target unter Linux konfigurieren
| Hinweis: Bitte beachten Sie, dass dieser Artikel / diese Kategorie sich entweder auf ältere Software/Hardware Komponenten bezieht oder aus sonstigen Gründen nicht mehr gewartet wird. Diese Seite wird nicht mehr aktualisiert und ist rein zu Referenzzwecken noch hier im Archiv abrufbar. |
|---|
Um das Direct Server Return (DSR) zu nutzen, muss am Target-Server zum einen ein loopback-device mit der IP-Adresse des virtuellen Servers erstellt werden und unter Linux des weiteren dafür gesorgt werden, dass diese IP-Adresse nicht ins Netzwerk antwortet (Stichwort arp-flux-Problem). Hierfür müssen für alle physikalisch vorhandenen Interfaces sysctl-Parameter gesetzt werden. Um dies zu vereinfachen, kann man folgendes Init-Script benutzen
#! /bin/bash
### BEGIN INIT INFO
# Provides: BalanceNG Agent
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# chkconfig: 2345 99 99
# Short-Description: Initscript for BalanceNG-agent
# Description: This script starts/stops the BalanceNG-agent
### END INIT INFO
# Author: Peter Ackermann <packermann@thomas-krenn.com>
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="balanceNG Loadbalancer-Agent"
NAME=bngagent
DAEMON=/sbin/$NAME
DAEMON_ARGS="--options args"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
# DSR-Specific options. If setting DSRENABLE to "Yes", arp-flux-problem will be solved and the proper loopback will be created
DSRENABLE=Yes
# Specifiy here the IP-Address of the virtual Server on the LoadBalancer (important for DSR)
VSERVER=127.0.0.1
# Start the bngagent?
DAEMONSTART=No
# Load the VERBOSE setting and other rcS variables on debian-based distro
if [ -e /etc/debian_version ]; then
. /lib/init/vars.sh
else
VERBOSE="yes"
fi
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
do_start()
{
if [ $DSRENABLE == "Yes" ]; then
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
find /proc/sys/net/ipv4/conf/eth*/arp_ignore | awk '{ system("echo 1 > "$1); }'
find /proc/sys/net/ipv4/conf/eth*/arp_announce | awk '{ system("echo 2 > "$1); }'
ifconfig lo:0 $VSERVER netmask 255.255.255.255 -arp up
fi
if [ $DAEMONSTART == "Yes" ]; then
$DAEMON -0 439
fi
return 0
}
#
# Function that stops the daemon/service
#
do_stop()
{
if [ $DAEMONSTART == "Yes" ]; then
pkill $DAEMON
fi
return 0
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
do_stop
do_start
return 0
}
case "$1" in
start)
[ "$VERBOSE" != no ] && echo -n $"Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && exit 0 ;;
2) [ "$VERBOSE" != no ] && exit 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && echo -n $"Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && exit 0 ;;
2) [ "$VERBOSE" != no ] && exit 1 ;;
esac
;;
restart|force-reload)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
echo -n $"Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) exit 0 ;;
1) exit 1 ;; # Old process is still running
*) exit 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
exit 1
;;
esac
;;
*)
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 3
;;
esac
:
Im oberen Bereich des Scriptes sind folgende Parameter zu setzen:
DSRENABLE
Legt fest, ob die für DSR nötigen sysctl-Parameter aktiviert werden sollen und das loopback-device lo:0 konfiguriert werden soll
VSERVER
Gibt die IP-Adresse an, die für das loopback-device konfiguriert werden soll. Diese muss mit der IP-Adresse identisch sein, die am LoadBalancer als Server-IP konfiguriert ist
DAEMONSTART
Hiermit kann festgelegt werden, ob ggf. der bngagent mitgestartet werden soll. Dieser muss unter dem binary und Pfad zu finden sein, wie in den Variablen NAME und DAEMON festgelegt ist (Standard /sbin/bngagent)
Das Init-Script funktioniert sowohl an Debian-basierten-Systemen als auch an RedHat-basierten.
