我在专用服务器上使用 Debian Wheezy,该服务器同时使用 IPv4 和 IPv6。
ifconfig eth0
eth0 Link encap:Ethernet HWaddr 11:11:11:11:11:11
inet adr:90.0.0.1 Bcast:90.0.0.255 Masque:255.255.255.0
adr inet6: fe80::21c:c0ff:feb9:829c/64 Scope:Lien
adr inet6: 2001:a100:1:bbbb::1/64 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1544 errors:0 dropped:0 overruns:0 frame:0
TX packets:2199 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 lg file transmission:1000
RX bytes:304146 (297.0 KiB) TX bytes:1376282 (1.3 MiB)
(几分钟后,RX 掉线计数器增加。)
猫/等/网络/接口
我首先使用了“gateway”关键字,但是没有效果,所以我尝试在文件中添加路由,但是也没有效果。
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 90.0.0.1
netmask 255.255.255.0
network 90.0.0.0
broadcast 90.0.0.255
gateway 90.0.0.254
iface eth0 inet6 static
address 2001:a100:1:bbbb::1
netmask 64
# gateway 2001:a100:1:bbff:ff:ff:ff:ff
up ip -6 route add ::/0 via 2001:a100:1:bbff:ff:ff:ff:ff dev eth0
down ip -6 route del ::/0 via 2001:a100:1:bbff:ff:ff:ff:ff dev eth0
ip -6 路由显示
这些是重启服务器几分钟后显示的路线。
2001:a100:1:bbbb::/64 dev eth0 proto kernel metric 256
2001:a100:1:bb00::/56 dev eth0 proto kernel metric 256 expires 2591959sec
fe80::/64 dev eth0 proto kernel metric 256
default via fe80::224:c3ff:fe84:400 dev eth0 proto ra metric 1024 expires 1759sec
default via fe80::224:c3ff:fe84:800 dev eth0 proto ra metric 1024 expires 1759sec
问题
为什么不考虑我的默认路线(无论在 中使用关键字
gateway
或,ip -6 route add
/etc/network/interfaces
在启动期间?请注意,如果我手动添加路由,它会完美运行,我可以使用 IPv6 向互联网发送和接收信息。(问题是让它自动化。)那些奇怪的内核路由是什么,会过期吗?我需要它们吗?我的服务器与 rooter (2001:a100:1:bbff:ff:ff:ff:ff) 直接连接到同一个网络,而 rooter 本身直接连接到互联网。
编辑
ifdown --force eth0; ifup --verbose eth0;
Configuring interface eth0=eth0 (inet)
run-parts --verbose /etc/network/if-pre-up.d
ip addr add 90.0.0.1/255.255.255.0 broadcast 90.0.0.255 dev eth0 label eth0
ip link set dev eth0 up
ip route add default via 90.0.0.254 dev eth0
run-parts --verbose /etc/network/if-up.d
run-parts: executing /etc/network/if-up.d/avahi-daemon
run-parts: executing /etc/network/if-up.d/bind9
run-parts: executing /etc/network/if-up.d/mountnfs
run-parts: executing /etc/network/if-up.d/ntpdate
run-parts: executing /etc/network/if-up.d/openssh-server
run-parts: executing /etc/network/if-up.d/openvpn
run-parts: executing /etc/network/if-up.d/postfix
run-parts: executing /etc/network/if-up.d/upstart
Configuring interface eth0=eth0 (inet6)
run-parts --verbose /etc/network/if-pre-up.d
modprobe -q net-pf-10 > /dev/null 2>&1 || true # ignore failure.
sysctl -q -e -w net.ipv6.conf.eth0.autoconf=0
ip link set dev eth0 up
ip -6 addr add 2001:a100:1:bbbb::1/64 dev eth0
ip -6 route add default via 2001:a100:1:bbff:ff:ff:ff:ff dev eth0
RTNETLINK answers: File exists
Failed to bring up eth0.
答案1
这些sysctl
设置可能对您有帮助吗?
net.ipv6.conf.all.autoconf=0
net.ipv6.conf.all.accept_ra=0
答案2
/etc/network/interfaces 中的以下配置对我有用:
iface eth0 inet6 static
address 2001:a100:1:bbbb::1
netmask 64
up ip -6 route add default via 2001:a100:1:bbff:ff:ff:ff:ff
down ip -6 route del default via 2001:a100:1:bbff:ff:ff:ff:ff