Linux
從 ipv6 dhcp 伺服器獲取 IP
我有以下實驗室:
DHCP 伺服器
$$ Centos 6 $$
/etc/dhcp/dhcpd6.conf default-lease-time 2592000; preferred-lifetime 604800; option dhcp-renewal-time 3600; option dhcp-rebinding-time 7200; allow leasequery; option dhcp6.info-refresh-time 21600; dhcpv6-lease-file-name "/var/lib/dhcpd/dhcpd6.leases"; subnet6 3ffe:501:ffff:100::/64 { } host ipv6host { hardware ethernet 53:54:00:70:1d:ed; fixed-address6 3ffe:501:ffff:100::222; if packet(0,1) = 1 { log(debug,"Request match!"); } } # ip -6 addr show 5: eth1.30@if3: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 inet6 3ffe:501:ffff:100::4/64 scope global valid_lft forever preferred_lft forever
在客戶端沒有特殊配置。然後,執行 dhcp 伺服器,我得到以下輸出:
Internet Systems Consortium DHCP Server 4.1.1-P1 Copyright 2004-2010 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/ Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file Wrote 0 deleted host decls to leases file. Wrote 0 new dynamic host decls to leases file. Wrote 0 leases to leases file. Bound to *:547 Listening on Socket/5/eth1.30/3ffe:501:ffff:100::/64 Sending on Socket/5/eth1.30/3ffe:501:ffff:100::/64 Solicit message from fe80::5054:ff:fe70:1ded port 546, transaction ID 0xDF54D000 Request match! Request match! Sending Advertise to fe80::5054:ff:fe70:1ded port 546 Solicit message from fe80::5054:ff:fe70:1ded port 546, transaction ID 0xDF54D000 Request match! Request match! Sending Advertise to fe80::5054:ff:fe70:1ded port 546 ... and more
在客戶端上,我得到以下執行客戶端:
dhclient -6 -d eth1 Internet Systems Consortium DHCP Client 4.1.1-P1 Copyright 2004-2010 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/ Bound to *:546 Listening on Socket/eth1 Sending on Socket/eth1 PRC: Soliciting for leases (INIT). XMT: Forming Solicit, 0 ms elapsed. XMT: X-- IA_NA 00:70:1d:ed XMT: | X-- Request renew in +3600 XMT: | X-- Request rebind in +5400 XMT: Solicit on eth1, interval 1010ms. XMT: Forming Solicit, 1010 ms elapsed. XMT: X-- IA_NA 00:70:1d:ed XMT: | X-- Request renew in +3600 XMT: | X-- Request rebind in +5400 XMT: Solicit on eth1, interval 2070ms.
如您所見,似乎伺服器從客戶端獲取請求並匹配主機條目。我不知道為什麼客戶端沒有獲得IP。
注意:客戶端是一個虛擬機,在虛擬機管理程序中,vnic 連接到帶有 eth1.30 的網橋。節點之間的流量還可以。
解決了!
問題是ip6tables。預設規則阻止來自 DHCP 伺服器的廣告。
service ip6tables stop
會解決這個問題。看看其他答案的評論,因為我使用的範圍似乎不好。
重要。至少有 2 個 Centos 6 盒子(伺服器和客戶端)使用 MAC 地址分配 ip 工作正常。
來源: http ://www.redhat.com/archives/anaconda-devel-list/2010-November/msg00172.html
在 DHCPv6 中,客戶端不再使用其 MAC 地址來辨識,而是使用 DUID(客戶端的所有介面都相同,因此理論上更容易辨識客戶端)。因此,您還應該將主機定義放在子網塊中。根據介面和 DUID 組合,系統可能具有不同的地址。這是來自Linux IPv6 how-to的範例:
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 2001:4860:4860::8888; 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; } }
您可以從伺服器日誌中獲取客戶端的 DUID,也可以從客戶端中提取它。這是一個解析
dhcp6c
為儲存生成的 DUID 而創建的文件的範例:hexdump -e '"%07.7_ax " 1/2 "%04x" " " 14/1 "%02x:" "\n"' /var/lib/dhcpv6/dhcp6c_duid
所有範例均基於操作指南中的範例。