赞
踩
4、启动RADVD和重启kea
#!/bin/sh
#
# This script is called with the following parameters:
# interface tty speed local-address remote-address ipparam
#
# Start router advertisements on this link.
# Based on radvd 0.5.0 behaviour
DEVICE="$1"
CFGFILE="/etc/radvd.conf-$DEVICE"
PIDFILE="/var/run/radvd/radvd-$DEVICE.pid"
EXEFILE="/usr/sbin/radvd"
LOGFILE="/var/log/pppoe-server"
GenerateRadvdConfig()
{
echo "[`date +%H`:`date +%M`:`date +%S`][$0] generate radvd config for $DEVICE" >> "$LOGFILE"
cp /etc/radvd.conf "$CFGFILE"
if [ $? -eq 0 ];then
sed -i "s/eno1/$DEVICE/g" "$CFGFILE"
else
echo "[`date +%H`:`date +%M`:`date +%S`][$0] cp /etc/radvd.conf failed" >> "$LOGFILE"
fi
}
RunRadvd()
{
if [ -x "$EXEFILE" -a -f "$CFGFILE" ]; then
echo "[`date +%H`:`date +%M`:`date +%S`][$0] $EXEFILE -u radvd -C $CFGFILE -p $PIDFILE " >> "$LOGFILE"
"$EXEFILE" -u radvd -C "$CFGFILE" -p "$PIDFILE"
else
echo "[`date +%H`:`date +%M`:`date +%S`][$0] $EXEFILE is not executable, or $CFGFILE is not existed " >> "$LOGFILE"
fi
}
ModifyKeaConfig()
{
local configPath="/usr/local/etc/kea/kea.conf"
local lineNum=`grep \"interface\":\"eno1\" "$configPath" -n |cut -d : -f 1`
local samplePath="/etc/ppp/ipv6-up.d/kea_pool.sample"
#配置地址池
sed -i "s/eno1/$DEVICE/g" "$samplePath"
sed -i "$lineNum r $samplePath" "$configPath"
sed -i "s/$DEVICE/eno1/g" "$samplePath"
}
##################################################### main #####################################
echo "[`date +%H`:`date +%M`:`date +%S`][$0] $DEVICE up" >> "$LOGFILE"
#1.生成radvd配置,并启动radvd进程
GenerateRadvdConfig
RunRadvd
#2.修改kea-dhcp6的配置,并重启服务
ModifyKeaConfig
keactrl stop
keactrl start
},
{
"subnet": "2001:10:10:10::/64",
"pools": [ { "pool": "2001:10:10:10::1-2001:10:10:10::ffff" } ],
"pd-pools":
[
{
"prefix": "3000:6666:6666:6666::",
"prefix-len": 48,
"delegated-len": 64
}
],
"interface":"eno1"
#!/bin/sh
#
# This script is called with the following parameters:
# interface tty speed local-address remote-address ipparam
#
# Kill the router advertisement daemon on this interface.
# The killing procedure is copied from RedHat 6.0 initscripts.
DEVICE="$1"
PIDFILE="/var/run/radvd/radvd-$DEVICE.pid"
CFGFILE="/etc/radvd.conf-$DEVICE"
LOGFILE="/var/log/pppoe-server"
StopRadvd()
{
local PID="$(cat "$PIDFILE")"
if [ "$PID" != "" ]; then
echo "[`date +%H`:`date +%M`:`date +%S`][$0] kill -TERM $PID" >> "$LOGFILE"
kill -TERM "$PID"
fi
rm -f "$PIDFILE"
rm -f "$CFGFILE"
}
ModifyKeaConfig()
{
local configPath="/usr/local/etc/kea/kea.conf"
local endLineNum=`grep \"interface\":\""$DEVICE"\" "$configPath" -n |cut -d : -f 1`
local startLineNum=`expr $endLineNum - 12`
# 删除地址池
sed -i "${startLineNum},${endLineNum}d" "$configPath"
}
##################################################### main #####################################
echo "[`date +%H`:`date +%M`:`date +%S`][$0] $DEVICE down" >> "$LOGFILE"
StopRadvd
ModifyKeaConfig
keactrl stop
keactrl start
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。