加载中...
IPV6服务器搭建

IPV6服务器搭建

搭建环境:ubuntu
使用工具:isc-dhcp-server、radvd

一、虚拟机配置


虚拟机需要配置网络为桥接。
主要目的是为了,让该虚拟机能给所在的局域网设备自动分配ipv6

二、isc-dhcp-server工具安装

dhcpd工具主要用于和udhcpc6交互,分配ipv6给客户端
1、安装isc-dhcp-server工具

```bash
sudo apt update
sudo apt install isc-dhcp-server


````bash
#安装过程可能会看到因为一些什么奇怪的锁,如下所示,可以根据提示kill掉对应的进程或者强制解锁直接删除文件。
Unable to acquire the dpkg frontend lock

#杀掉占用的进程
sudo kill PID

#强制解锁
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock

2、配置dhcpd配置文件

#打开/etc/dhcp/dhcpd6.conf文件,若没有则创建
#打开该文件的时候可能会遇到文件只读无法写使用下面命令即可
sudo chmod 777 /etc/dhcp/dhcpd6.conf

#dhcpd6.conf配置
# Server configuration file example for DHCPv6
# From the file used for TAHI tests - addresses chosen
# to match TAHI rather than example block.

# IPv6 address valid lifetime
#  (at the end the address is no longer usable by the client)
#  (set to 30 days, the usual IPv6 default)
default-lease-time 2592000;

# IPv6 address preferred lifetime
#  (at the end the address is deprecated, i.e., the client should use
#   other addresses for new connections)
#  (set to 7 days, the	usual IPv6 default)
preferred-lifetime 604800;

# T1, the delay before Renew
#  (default is 1/2 preferred lifetime)
#  (set to 1 hour)
option dhcp-renewal-time 3600;

# T2, the delay before Rebind (if Renews failed)
#  (default is 3/4 preferred lifetime)
#  (set to 2 hours)
option dhcp-rebinding-time 7200;

# Enable RFC 5007 support (same than for DHCPv4)
allow leasequery;

# Global definitions for name server address(es) and domain search list
option dhcp6.name-servers 3ffe:501:ffff:100:200:ff:fe00:3f3e;
option dhcp6.domain-search "test.example.com","example.com";

# Set preference to 255 (maximum) in order to avoid waiting for
# additional servers when there is only one
##option dhcp6.preference 255;

# Server side command to enable rapid-commit (2 packet exchange)
##option dhcp6.rapid-commit;

# The delay before information-request refresh
#  (minimum is 10 minutes, maximum one day, default is to not refresh)
#  (set to 6 hours)
option dhcp6.info-refresh-time 21600;

# Static definition (must be global)
#host myclient {
#	# The entry is looked up by this
#	host-identifier option
#		dhcp6.client-id 00:01:00:01:00:04:93:e0:00:00:00:00:a2:a2;
#
#	# A fixed address
#	fixed-address6 3ffe:501:ffff:100::1234;
#
#	# A fixed prefix
#	fixed-prefix6 3ffe:501:ffff:101::/64;
#
#	# Override of the global definitions,
#	# works only when a resource (address or prefix) is assigned
#	option dhcp6.name-servers 3ffe:501:ffff:100:200:ff:fe00:4f4e;
#
#	# For debug (to see when the entry statements are executed)
#	#  (log "sol" when a matching Solicitation is received)
#	##if packet(0,1) = 1 { log(debug,"sol"); }
#}
#
#host otherclient {
#        # This host entry is hopefully matched if the client supplies a DUID-LL
#        # or DUID-LLT containing this MAC address.
#        hardware ethernet 01:00:80:a2:55:67;
#
#        fixed-address6 3ffe:501:ffff:100::4321;
#}

subnet6 2001:db8:1:0::/64 {
	range6 2001:db8:1:0::50 2001:db8:1:0::100;
	option dhcp6.name-servers 2001:4860:4860::8888;
}

# The subnet where the server is attached
#  (i.e., the server has an address in this subnet)
#subnet6 3ffe:501:ffff:100::/64 {
#	# Two addresses available to clients
#	#  (the third client should get NoAddrsAvail)
#	range6 3ffe:501:ffff:100::10 3ffe:501:ffff:100::11;
#
#	# Use the whole /64 prefix for temporary addresses
#	#  (i.e., direct application of RFC 4941)
#	range6 3ffe:501:ffff:100:: temporary;
#
#	# Some /64 prefixes available for Prefix Delegation (RFC 3633)
#	prefix6 3ffe:501:ffff:100:: 3ffe:501:ffff:111:: /64;
#}

# A second subnet behind a relay agent
#subnet6 3ffe:501:ffff:101::/64 {
#	range6 3ffe:501:ffff:101::10 3ffe:501:ffff:101::11;
#
#	# Override of the global definitions,
#	# works only when a resource (address or prefix) is assigned
#	option dhcp6.name-servers 3ffe:501:ffff:101:200:ff:fe00:3f3e;
#
#}

# A third subnet behind a relay agent chain
#subnet6 3ffe:501:ffff:102::/64 {
#	range6 3ffe:501:ffff:102::10 3ffe:501:ffff:102::11;
#}

三、radvd工具安装

radvd工具主要用于广播网关

sudo apt radvd

#创建/etc/radvd.conf,若有则无需创建

#添加读写权限
sudo chmod 777 /etc/radvd.conf

#配置/etc/radvd.conf文件
interface ens33{
	AdvSendAdvert on;
	MinRtrAdvInterval 30;
	MaxRtrAdvInterval 600;
	AdvManagedFlag on;
	AdvOtherConfigFlag on;
	AdvLinkMTU 1500;
	AdvSourceLLAddress on;
	AdvDefaultPreference high;
	prefix 2001:db8:1:0::/64
	{
	AdvOnLink on;
	AdvAutonomous off;
	AdvRouterAddr on;
	AdvPreferredLifetime 3600;
	AdvValidLifetime 7200;
	};
route 2001:db8:1:0::/64{
};
};

四、启动服务

1、启动radvd服务

service radvd start

radvd启动成功
2、启动dhcpd服务

#设置ubuntu的ipv6 ip
sudo ifconfig ens33 inet6 add 2001:db8:1:0::1/64
#启动dhcpd
sudo dhcpd -6 -d -cf /etc/dhcp/dhcpd6.conf ens33

启动过程及分配ipv6打印

上一篇:
udhcpc6嵌入式获取IPV6
下一篇:
linux usb设备数量和类型识别
本文目录
本文目录