Ubuntu 搭建 DHCP ivp6 server 步驟
1、安裝 DHCP server
sudo apt-get install isc-dhcp-server
2、修改配置檔案 /etc/dhcp/dhcpd6.conf
default-lease-time 2592000; preferred-lifetime 604800; option dhcp-renewal-time 3600; 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"; option dhcp6.info-refresh-time 21600; # The subnet where the server is attached subnet6 2022:: /64 { # Range for clients range6 2022::db8:0:1:129 2022::db8:0:1:139; # Range for clients requesting a temporary address range6 2022:: /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 2022::db8:0:1:100 2022::db8:0:1: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 2022::db8:0:1:127; } }
3、新建資料檔案
touch /var/lib/dhcp/dhcpd6.leases
chmod 777 /var/lib/dhcp/dhcpd6.leases #賦予許可權
4、修改網路卡介面為server網口,配置靜態地址(使用vim工具,vim /etc/netplan/01-network-manager-all.yaml,並執行netplan apply)
5、啟動dhcp server服務
例如我現在網路卡名為enp2s0,則命令為: /usr/sbin/dhcpd -6 -d -cf /etc/dhcp/dhcpd6.conf enp2s0
6、安裝 radvd(實現區域網路由功能)
sudo apt-get install radvd
7、新建配置檔案,注意檔案許可權不能為777,可以使用755
touch /etc/radvd.conf
chmod 755 /etc/radvd.conf
修改配置檔案內容 vim /etc/radvd.conf
#log-level 8 #log-mode full #stateless interface enp2s0 { AdvSendAdvert on; AdvOtherConfigFlag on; AdvManagedFlag on; MinRtrAdvInterval 10; MaxRtrAdvInterval 15; AdvDefaultPreference medium; AdvDefaultLifetime 45; prefix 2022:: /64 { AdvOnLink on; AdvAutonomous off; AdvRouterAddr on; AdvPreferredLifetime 3600; AdvValidLifetime 7200; }; route 2022:: /64 { }; };
8、啟動 radvd 路由服務,主要其中配置資訊要和網路卡設定靜態 IP 對應
9、測試執行