我正在使用最新更新的 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