無法在 Debian 上取得 IPv6 位址

無法在 Debian 上取得 IPv6 位址

我正在使用帶有最新更新的 Debian 7。

我從我的提供者那裡獲得了一組 IPv6 位址,並且根據提供者的說法,DHCP 伺服器已設置,以便我應該自動獲取 IP(我甚至詢問過他們)。但這不起作用。我自動獲得 IPv4,所以工作正常。經過一番谷歌搜尋等後,我發現文件 /etc/network/interfaces 應該要負責。這是它的起始位置:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp

這是起始位置的 ifconfig -a (IPv4 位址已更改,因為我不想轉儲我的真實 ipv4,IPv6 未受影響):

sudo ifconfig -a
[sudo] password for **:
eth0      Link encap:Ethernet  HWaddr <**>
          inet addr:188.105.484.221  Bcast:188.105.484.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe8c:3b20/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3290 errors:0 dropped:0 overruns:0 frame:0
          TX packets:304 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:407068 (397.5 KiB)  TX bytes:36628 (35.7 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1104 (1.0 KiB)  TX bytes:1104 (1.0 KiB)

鏈路本地 Ipv6,這也不是 DHCP 伺服器想要給我的,所以不好。所以我改變了/etc/network/interfaces:

 cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp
iface eth0 inet6 dhcp

然後我刷新了我的防火牆規則,因為我讀到防火牆也很煩人。那麼:

ifdown eth0 && ifup eth0
Internet Systems Consortium DHCP Client 4.2.2
Copyright 2004-2011 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/eth0/56:54:00:7b:3b:20
Sending on   LPF/eth0/56:54:00:7b:3b:20
Sending on   Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 4
DHCPREQUEST on eth0 to 255.255.255.255 port 67
DHCPOFFER from 188.105.484.254
DHCPACK from 188.105.484.254
bound to 188.105.484.221 -- renewal in 38715 seconds.

然後它就掛起並等待。它獲得了 IPv4,然後似乎想要開始尋找 ipv6,但它沒有或其他什麼。 ifconfig -a 看起來和以前一樣。我究竟做錯了什麼?我應該如何取得 ipv6 位址?

- - 編輯 - -

我使用靜態 ip 使其工作:/etc/network/interfaces(同樣,ipv6 位址不是我實際擁有的位址)

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp
#iface eth0 inet6 auto
#       accept_ra 1
#iface eth0 inet6 dhcp
#       accept_ra 1
iface eth0 inet6 static
        address 2a01:9b8:aaf:1dg::1
        gateway 2a01:9b8:aaf::1
        netmask 48

答案1

這取決於您的提供者使用的是無狀態 DHCPv6 還是有狀態 DHCPv6。

在無狀態 DHCPv6 中,您的 IP 位址實際上是透過 SLAAC 設定的,並且 DHCPv6 伺服器僅提供 DNS 伺服器位址、NTP 伺服器位址等。

在 Debian 7 中,這個/etc/network/interfaces設定可用於 SLAAC 或無狀態 DHCPv6:

iface eth0 inet6 auto

在有狀態 DHCPv6 中,DHCPv6 伺服器也提供 IPv6 位址分配;不使用 SLAAC。配置如下:

iface eth0 inet6 dhcp

相關內容