ubuntu下radvd,dhcpv6

上篇讲了ipV4 DHCP server.本篇继续讲述ipV6 server。环境如下
A: Ubuntu 14.04 + 有线网卡(eth0) + 无线网卡(wlan0)
B: Windows 7 + 有线网卡 + 无线网卡
A,B的无线网卡都连接到家庭无线路由器,网关为192.168.1.1,可以上互联网。A,B的有线网卡通过网线直连,A作为IPv6 server和网关,为B的有线网卡分配IPV6地址

一.A使用radvd(Router AdvertisementDaemon)为B分配ipv6地址

1.sudo vim /etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 10.5.5.1
netmask 255.255.255.224
network 10.10.10.0
broadcast 10.5.5.31
#auto eth0
iface eth0 inet6 static
address 2001:db8::1
netmask 64
2. sudo apt-get install radvd

3. vi /etc/radvd.conf (需新建该文件),如下面几行

interface eth0 {
	AdvSendAdvert on;
	AdvManagedFlag off;
	AdvOtherConfigFlag off;
	prefix 2001:db8::/64{
		AdvOnLink on;
		AdvAutonomous on;
		AdvRouterAddr off;
	};
};
4. 在/etc/sysctl.conf 中打开 net.ipv6.conf.all.forwarding=1
5. sudo /etc/init.d/radvd start
(如果在 radvd 运行状态下重启机器,radvd 会在开机后自动运行)
6. 在B上运行ipconfig
以太网适配器 本地连接:

   连接特定的 DNS 后缀 . . . . . . . :
   IPv6 地址 . . . . . . . . . . . . : 2001:db8::2ca1:fa3d:7f0b:611b
   临时 IPv6 地址. . . . . . . . . . : 2001:db8::5130:67e5:bd0:f297
   本地链接 IPv6 地址. . . . . . . . : fe80::2ca1:fa3d:7f0b:611b%11
   IPv4 地址 . . . . . . . . . . . . : 10.5.5.26
   子网掩码  . . . . . . . . . . . . : 255.255.255.224
   默认网关. . . . . . . . . . . . . : fe80::beae:c5ff:fe65:766c%11
                                       10.5.5.1

A上运行ifconfig

eth0      Link encap:以太网  硬件地址 bc:ae:c5:65:76:6c  
          inet 地址:10.5.5.1  广播:10.5.5.31  掩码:255.255.255.224
          inet6 地址: fe80::beae:c5ff:fe65:766c/64 Scope:Link
          inet6 地址: 2001:db8::1/64 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  跃点数:1
          接收数据包:1475 错误:0 丢弃:0 过载:0 帧数:0
          发送数据包:323 错误:0 丢弃:0 过载:0 载波:0
          碰撞:0 发送队列长度:1000 
          接收字节:132185 (132.1 KB)  发送字节:32086 (32.0 KB)

7.连通性测试

A上:
ping6 -I eth0 2001:db8::2ca1:fa3d:7f0b:611b

PING 2001:db8::2ca1:fa3d:7f0b:611b(2001:db8::2ca1:fa3d:7f0b:611b) from 2001:db8::1 eth0: 56 data bytes
64 bytes from 2001:db8::2ca1:fa3d:7f0b:611b: icmp_seq=1 ttl=64 time=73.9 ms
64 bytes from 2001:db8::2ca1:fa3d:7f0b:611b: icmp_seq=2 ttl=64 time=0.398 ms
PING fe80::2ca1:fa3d:7f0b:611b(fe80::2ca1:fa3d:7f0b:611b) from fe80::beae:c5ff:fe65:766c eth0: 56 data bytes
64 bytes from fe80::2ca1:fa3d:7f0b:611b: icmp_seq=1 ttl=64 time=0.699 ms
B上:

ping 2001:db8::1

C:\Windows\system32>ping 2001:db8::1

正在 Ping 2001:db8::1 具有 32 字节的数据:
来自 2001:db8::1 的回复: 时间=464ms
来自 2001:db8::1 的回复: 时间=62ms

二、使用isc-dhcp-server为B分配IPv6地址

A:
1.sudo apt-get install isc-dhcp-server
2.sudo vim /etc/network/interfaces
配置本机IPv6地址2001:db8:0:1::2

3.sudo vim /etc/dhcp/dhcpd6.conf

default-lease-time 600;
max-lease-time 7200; 
log-facility local7; 
subnet6 2001:db8:0:1::/64 {
        # Range for clients
        range6 2001:db8:0:1::129 2001:db8:0:1::254;

        # Range for clients requesting a temporary address
        range6 2001:db8:0:1::/64 temporary;

        # Additional options
        option dhcp6.name-servers fec0:0:0:1::1;
        option dhcp6.domain-search "domain.example";

        # Prefix range for delegation to sub-routers
        prefix6 2001:db8:0:100:: 2001:db8:0:f00:: /56;

        # Example for a fixed host address
        host specialclient {
    		host-identifier option dhcp6.client-id 00:01:00:01:4a:1f:ba:e3:60:b9:1f:01:23:45;
        	fixed-address6 2001:db8:0:1::127;
    	} 
}

4.B上运行ipconfig

以太网适配器 本地连接:

   连接特定的 DNS 后缀 . . . . . . . : domain.example
   IPv6 地址 . . . . . . . . . . . . : 2001:db8:0:1::254
   本地链接 IPv6 地址. . . . . . . . : fe80::2ca1:fa3d:7f0b:611b%11
   自动配置 IPv4 地址  . . . . . . . : 169.254.97.27
   子网掩码  . . . . . . . . . . . . : 255.255.0.0
   默认网关. . . . . . . . . . . . . : ::
此时ping 2001:db8:0:1::2 不通

netsh interface ipv6 add route ::/0 "本地连接" 2001:db8:0:1::254 publish=yes
C:\Windows\system32>ping 2001:db8:0:1::2

正在 Ping 2001:db8:0:1::2 具有 32 字节的数据:
来自 2001:db8:0:1::2 的回复: 时间<1ms
来自 2001:db8:0:1::2 的回复: 时间<1ms
来自 2001:db8:0:1::2 的回复: 时间<1ms
A上ping 2001:db8:0:1::254 连通

三、使用wide-dhcpv6-server给B分配IPv6地址
A:
1.sudo apt-get install wide-dhcpv6-server
2.sudo vim /etc/network/interfaces
添加IPv6地址2001:db8:1:2::120
3.sudo vim /etc/wide-dhcpv6/dhcp6s.conf
# The followings are a sample configuration to provide a DNS server address
# for every client as well as to delegate a permanent IPv6 prefix
# 2001:db8:1111::/48 to a client whose DUID is 00:01:00:01:aa:bb.

option domain-name-servers 2001:db8::35;

host kame {
	duid 00:01:00:01:aa:bb;
	prefix 2001:db8:1111::/48 infinity;
};

# The followings are a sample configuration to provide an IPv6 address
# from an address pool 2001:db8:1:2::1000-2000 for 3600[s].
# Note. You have to send an RA to fxp0; otherwise a client cannot be sure 
# about the prefix-length and the default router.  If you want to prevent
# stateless address configuration via RA, please set the autonomous-flag to
# OFF in your RA configuration.

interface eth0 {
	address-pool pool1 3600;
};

pool pool1 {
	range 2001:db8:1:2::1000 to 2001:db8:1:2::2000 ;
};

4.同实验二验证。


参考文档:

ISC Dynamic Host Configuration Server (dhcpd)

Dynamic Host Configuration v6 Server (dhcp6s)

Ubuntu 11.04 DHCP server 和 ipv6 备忘

Linux IPv6 HOWTO中文

IPV6 DHCP server

你可能感兴趣的:(ubuntu下radvd,dhcpv6)