##物理口
###client端设置:
######1、sysctl 修改内核参数,使能接口ipv6,是能全局ipv6转发,使能接口 accept_ra。
# 是能接口ipv6,默认 disable
net.ipv6.conf.eth2.disable_ipv6 = 0
# 允许接口接受ra报文,Obtain IPv6 address on wan interface by Stateless autoconfiguration (SLAAC)
net.ipv6.conf.all.forwarding = 1
net.ipv6.conf.eth2.accept_ra = 2
net.ipv6.conf.eth2.autoconf = 1
# 测试需要,不使用临时地址
net.ipv6.conf.all.use_tempaddr = 0
net.ipv6.conf.default.use_tempaddr = 0
######2、修改/etc/sysconfig/network
NETWORKING_IPV6=yes
######3、修改 /etc/sysconfig/network-scripts/ifcfg-eth2(可以不做持久化)
DEVICE=eth2
ONBOOT=yes
NETBOOT=yes
NM_CONTROLLED=no
PEERDNS=yes
#BOOTPROTO=dhcp # 打开这个可以同时获取ipv4和ipv6地址
BOOTPROTO=dhcp6 # 打开这个只会获取ipv6的地址
DHCPV6C=yes
IPV6INIT=yes
IPV6_AUTOCONFIG=yes
######4、dhclient 的使用.
需要使用dhcp分配地址或域名等配置是需要使用dhclient,否者不需要,如slaac方式获取地址又静态配置dns等other infomation的情况,不需要任何dhcp的协商,只需要打开RA接受开关即可。
PPPoE的情况下,dhclient 作用在ppp口上即可,其他类似。
编码 | 测试 | |
---|---|---|
接受地址和other infomation | dhclient -6 eth2 --no-pid -nw | dhclient -6 eth2 --no-pid -v |
不接受地址,只接受other infomation。如静态配置ipv6地址,只需要dns地址等时候 | dhclient -6 -S eth2 --no-pid -nw | dhclient -6 -S eth2 --no-pid -v |
server端 dnsmasq配置
######1、配置/etc/sysconfig/network
NETWORKING_IPV6=yes
######2、内核参数,使能接口ipv6
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.eth2.disable_ipv6 = 0
######3、dnsmasq配置
无论是Autoconf、dhcp stateless、dhcpstateful都需要用到RA消息,告诉client能过提供的能力,RA报文由dnsmasq根据配置文件构造。RA消息报文可以包含的一些flag,这些flag会反应在dnsmasq的配置上,决定client端地址分配的方式:
IPv6 Router Advertisement (RA) messages can contain the following flags:
* M (“Managed address configuration”) – indicates that IPv6 addresses are available via DHCPv6. This is also referred to as Stateful DHCP.
* O (“Other configuration”) – no IPv6 address, but other configuration information like DNS etc. are available via DHCPv6. This is also referred to as Stateless DHCP.
* A (“Autonomous Address Configuration”) – indicates that the prefix present with th