当前位置:   article > 正文

Ubuntu IPv6 pppoe服务器搭建(基于Kea DHCP Server V1.2.0)_pppoe radvd.conf

pppoe radvd.conf
1、安装pppoe服务器
sudo apt-get install pppoe

2、配置pppoe服务器
(1) 修改/etc/ppp/chap-secrets,增加拨号用户名,密码:
增加一行:"chap"   *   "chap"    *

(2) 新增/etc/ppp/pppoe-server-options
增加一行:+ipv6(加号不能省略,否则拨号失败)

3、启动pppoe服务器
pppoe-server -I eth0 -L 10.10.10.49  -R 10.10.10.50  -N 50

注:
  • chap认证方式这样配置即可,pap还没有验证。
  • 按此配置客户端获取的只是link local地址。


4、启动RADVD和重启kea

  • 将/usr/share/doc/ppp/examples/scripts/ipv6-up.sample 拷贝为/etc/ppp/ipv6-up.d/ipv6-up,并修改如下:


#!/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

  • 在/etc/ppp/ipv6-up.d/下新建文件kea_pool.sample,并修改为:
        },
    {
      "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"


  • 将/usr/share/doc/ppp/examples/scripts/ipv6-down.sample拷贝为/etc/ppp/ipv6-down.d/ipv6-down,并修改为:
    #!/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
    
    
    



声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/320373
推荐阅读
相关标签
  

闽ICP备14008679号