Ubuntu20作为路由,设置IPv6 PPPoe slaac配置例子

Dnsmasq配置如下:

enable-ra
dhcp-range=::1,constructor:eth2,ra-only,12h
except-interface=ppp0

Wide-dhcpv6配置如下:

  profile default
{
   information-only;
  
  request domain-name-servers;
  request domain-name;

  script "/etc/wide-dhcpv6/dhcp6c-script";
};
interface ppp0 {
    # Request Prefix Delegation on ppp0, and give the received prefix id 0
    send ia-pd 0;
};

# Use subnets from the prefix with id 0
id-assoc pd 0 {
        prefix ::/64 infinity;
        prefix-interface eth2 {
        sla-len 0;
        sla-id 1;
        ifid 1;
    };
};
如果有多个内网网口,配置变更如下:

profile default
{
   information-only;
  
  request domain-name-servers;
  request domain-name;

  script "/etc/wide-dhcpv6/dhcp6c-script";
};
interface ppp0 {
    # Request Prefix Delegation on ppp0, and give the received prefix id 0
    send ia-pd 0;
};

# Use subnets from the prefix with id 0
id-assoc pd 0 {
        prefix ::/64 infinity;
              prefix-interface eth1 {
        sla-len 0;
        sla-id 1;
        ifid 1;
    };        prefix-interface eth2 {
        sla-len 0;
        sla-id 1;
        ifid 1;
    };
};

sysctl.conf部分配置如下:

net.ipv6.conf.eth2.accept_ra=2
net.ipv6.conf.ppp0.accept_ra=2
net.ipv6.conf.all.use_tempaddr=0
net.ipv6.conf.default.use_tempaddr=0

service服务文件如下:

[Unit]
Description=wide-dhcpv6
Before=dnsmasq.service
After=network.target 
[Service]
ExecStart=/usr/sbin/dhcp6c -c /etc/wide-dhcpv6/dhcp6c.conf -P default -d -D -f ppp0
RemainAfterExit=true

[Install]
WantedBy=multi-user.target

/etc/ppp/option配置文件部分如下:

+ipv6 ipv6cp-use-ipaddr