dhclient 参数说明:
-6 | Combined with only one of these switches: -S -T -N |
-S | Stateless Mode: Perform an information-only request over DHCPv6 to get stateless configuration parameters |
-T | IA_TA |
-N | IA_NA |
-P | IA_PD |
-g | For debugging. Set the giaddr field of all packets the client sends to the IP address specified. |
-s <IP/FQDN> | Specify the server IP address or FQDN |
-I <dhcp-client-identifier> |
|
-H <host-name> | host-name option to be sent to the server |
-V <vendor-class-identifier> | Specify the vendor-class-identifier option to send to the DHCP server. |
-cf <config-file> |
|
系统安装dhclient的时候给了一个config-file的模板,我们把这个模板copy到dhclient配置路径下,然后修改其内容
# cp /usr/share/doc/dhclient-4.2.5/dhclient6.conf.example /etc/dhcp/dhclient6.conf
# vi /etc/dhcp/dhclient6.conf
…..
script "sbin/dhclient-script";
interface "eth0" {
send dhcp6.client-id DUID;
send dhcp6.reconf-accept;
request;
# request dhcp6.name-servers, dhcp6.domain-search;
}
注:这里的request是dhclient向DHCP服务器要求的options list,比如DNS,SIP服务器地址等等
然后我们通过命令行验证是否可以从DHCP服务器获得v6地址:
# dhclient -6 -d eth0 //先release
# dhclient -6 -d -T -cf /etc/dhcp/dhclient6.conf
如果分配地址成功,可以用如下命令检查相关信息:
# more /var/lib/dhclient/dhclient6.leases
default-duid "\000\001\000\001 _\223\321\000\014)\331\017\203";
lease6 {
interface "eth0";
ia-na 29:d9:0f:83 {
starts 1489934110;
renew 3600;
rebind 5760;
iaaddr 2001:db8:ac:1e32::1 {
starts 1489934110;
preferred-life 7200;
max-life 7500;
}
}
option dhcp6.client-id 0:1:0:1:20:5f:93:d1:0:c:29:d9:f:83;
option dhcp6.server-id 0:1:0:1:20:60:dd:ba:0:c:29:53:70:87;
option dhcp6.name-servers 2001:db8::3,2001:db8::4;
}
如果希望开机以后自动通过DHCP获取v6地址,需要在网卡的配置文件里面增加相关配置
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
# Enable DHCPv6-PD client.
DHCPV6C=yes
DHCPV6C_OPTIONS="-P -cf /etc/dhcp/dhclient6.conf"
# Disable make_resolv_conf function in /sbin/dhclient-script.
PEERDNS=no
然后重启网络服务
# service network restart