dhcpv6 server test env building

来源:互联网 发布:温州市网络问政平台 编辑:程序博客网 时间:2024/06/06 02:47
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

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. auto lo  
  2. iface lo inet loopback  
  3.   
  4. auto eth0  
  5. iface eth0 inet static  
  6. address 10.5.5.1  
  7. netmask 255.255.255.224  
  8. network 10.10.10.0  
  9. broadcast 10.5.5.31  
  10. #auto eth0  
  11. iface eth0 inet6 static  
  12. address 2001:db8::1  
  13. netmask 64  
2. sudo apt-get install radvd
3. vi /etc/radvd.conf (需新建该文件),如下面几行
[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. interface eth0 {  
  2.     AdvSendAdvert on;  
  3.     AdvManagedFlag off;  
  4.     AdvOtherConfigFlag off;  
  5.     prefix 2001:db8::/64{  
  6.         AdvOnLink on;  
  7.         AdvAutonomous on;  
  8.         AdvRouterAddr off;  
  9.     };  
  10. };  
4. 在/etc/sysctl.conf 中打开 net.ipv6.conf.all.forwarding=1
5. sudo /etc/init.d/radvd start
(如果在 radvd 运行状态下重启机器,radvd 会在开机后自动运行)
6. 在B上运行ipconfig
[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. 以太网适配器 本地连接:  
  2.   
  3.    连接特定的 DNS 后缀 . . . . . . . :  
  4.    IPv6 地址 . . . . . . . . . . . . : 2001:db8::2ca1:fa3d:7f0b:611b  
  5.    临时 IPv6 地址. . . . . . . . . . : 2001:db8::5130:67e5:bd0:f297  
  6.    本地链接 IPv6 地址. . . . . . . . : fe80::2ca1:fa3d:7f0b:611b%11  
  7.    IPv4 地址 . . . . . . . . . . . . : 10.5.5.26  
  8.    子网掩码  . . . . . . . . . . . . : 255.255.255.224  
  9.    默认网关. . . . . . . . . . . . . : fe80::beae:c5ff:fe65:766c%11  
  10.                                        10.5.5.1  

A上运行ifconfig

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. eth0      Link encap:以太网  硬件地址 bc:ae:c5:65:76:6c    
  2.           inet 地址:10.5.5.1  广播:10.5.5.31  掩码:255.255.255.224  
  3.           inet6 地址: fe80::beae:c5ff:fe65:766c/64 Scope:Link  
  4.           inet6 地址: 2001:db8::1/64 Scope:Global  
  5.           UP BROADCAST RUNNING MULTICAST  MTU:1500  跃点数:1  
  6.           接收数据包:1475 错误:0 丢弃:0 过载:0 帧数:0  
  7.           发送数据包:323 错误:0 丢弃:0 过载:0 载波:0  
  8.           碰撞:0 发送队列长度:1000   
  9.           接收字节:132185 (132.1 KB)  发送字节:32086 (32.0 KB)  

7.连通性测试

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

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. PING 2001:db8::2ca1:fa3d:7f0b:611b(2001:db8::2ca1:fa3d:7f0b:611b) from 2001:db8::1 eth0: 56 data bytes  
  2. 64 bytes from 2001:db8::2ca1:fa3d:7f0b:611b: icmp_seq=1 ttl=64 time=73.9 ms  
  3. 64 bytes from 2001:db8::2ca1:fa3d:7f0b:611b: icmp_seq=2 ttl=64 time=0.398 ms  
[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. PING fe80::2ca1:fa3d:7f0b:611b(fe80::2ca1:fa3d:7f0b:611b) from fe80::beae:c5ff:fe65:766c eth0: 56 data bytes  
  2. 64 bytes from fe80::2ca1:fa3d:7f0b:611b: icmp_seq=1 ttl=64 time=0.699 ms  
B上:

ping 2001:db8::1

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. C:\Windows\system32>ping 2001:db8::1  
  2.   
  3. 正在 Ping 2001:db8::1 具有 32 字节的数据:  
  4. 来自 2001:db8::1 的回复: 时间=464ms  
  5. 来自 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

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. default-lease-time 600;  
  2. max-lease-time 7200;   
  3. log-facility local7;   
  4. subnet6 2001:db8:0:1::/64 {  
  5.         # Range for clients  
  6.         range6 2001:db8:0:1::129 2001:db8:0:1::254;  
  7.   
  8.         # Range for clients requesting a temporary address  
  9.         range6 2001:db8:0:1::/64 temporary;  
  10.   
  11.         # Additional options  
  12.         option dhcp6.name-servers fec0:0:0:1::1;  
  13.         option dhcp6.domain-search "domain.example";  
  14.   
  15.         # Prefix range for delegation to sub-routers  
  16.         prefix6 2001:db8:0:100:: 2001:db8:0:f00:: /56;  
  17.   
  18.         # Example for a fixed host address  
  19.         host specialclient {  
  20.             host-identifier option dhcp6.client-id 00:01:00:01:4a:1f:ba:e3:60:b9:1f:01:23:45;  
  21.             fixed-address6 2001:db8:0:1::127;  
  22.         }   
  23. }  

4.B上运行ipconfig

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. 以太网适配器 本地连接:  
  2.   
  3.    连接特定的 DNS 后缀 . . . . . . . : domain.example  
  4.    IPv6 地址 . . . . . . . . . . . . : 2001:db8:0:1::254  
  5.    本地链接 IPv6 地址. . . . . . . . : fe80::2ca1:fa3d:7f0b:611b%11  
  6.    自动配置 IPv4 地址  . . . . . . . : 169.254.97.27  
  7.    子网掩码  . . . . . . . . . . . . : 255.255.0.0  
  8.    默认网关. . . . . . . . . . . . . : ::  
此时ping 2001:db8:0:1::2 不通
[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. netsh interface ipv6 add route ::/0 "本地连接" 2001:db8:0:1::254 publish=yes  
[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. C:\Windows\system32>ping 2001:db8:0:1::2  
  2.   
  3. 正在 Ping 2001:db8:0:1::2 具有 32 字节的数据:  
  4. 来自 2001:db8:0:1::2 的回复: 时间<1ms  
  5. 来自 2001:db8:0:1::2 的回复: 时间<1ms  
  6. 来自 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
[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. # The followings are a sample configuration to provide a DNS server address  
  2. # for every client as well as to delegate a permanent IPv6 prefix  
  3. # 2001:db8:1111::/48 to a client whose DUID is 00:01:00:01:aa:bb.  
  4.   
  5. option domain-name-servers 2001:db8::35;  
  6.   
  7. host kame {  
  8.     duid 00:01:00:01:aa:bb;  
  9.     prefix 2001:db8:1111::/48 infinity;  
  10. };  
  11.   
  12. # The followings are a sample configuration to provide an IPv6 address  
  13. # from an address pool 2001:db8:1:2::1000-2000 for 3600[s].  
  14. # Note. You have to send an RA to fxp0; otherwise a client cannot be sure   
  15. # about the prefix-length and the default router.  If you want to prevent  
  16. # stateless address configuration via RA, please set the autonomous-flag to  
  17. # OFF in your RA configuration.  
  18.   
  19. interface eth0 {  
  20.     address-pool pool1 3600;  
  21. };  
  22.   
  23. pool pool1 {  
  24.     range 2001:db8:1:2::1000 to 2001:db8:1:2::2000 ;  
  25. };  

4.同实验二验证。

0 0
原创粉丝点击