在 Debian Wheezy 中的界面上禁用 IPv6?

在 Debian Wheezy 中的界面上禁用 IPv6?

我正在使用 Debian Wheezy:

$ uname -a
Linux openstack1 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64 GNU/Linux

我为 VirtualBox 设置了两个网络:

# Public network vboxnet0 (10.1.0.0/16)
VBoxManage hostonlyif create
VBoxManage hostonlyif ipconfig vboxnet0 --ip 10.1.0.254 --netmask 255.255.0.0

# Private network vboxnet1 (10.2.0.0/16)
VBoxManage hostonlyif create
VBoxManage hostonlyif ipconfig vboxnet1 --ip 10.2.0.254 --netmask 255.255.0.0
...

# VirtualBox Network
VBoxManage modifyvm openstack1 --nic1 nat \
  --nic2 hostonly --hostonlyadapter2 vboxnet0 \
  --nic3 hostonly --hostonlyadapter3 vboxnet1

在虚拟机中,我有以下内容/etc/network/interfaces

# The loopback network interface
auto lo
iface lo inet loopback

# Primary network interface
auto eth0
iface eth0 inet dhcp

# Public network (OpenStack)
auto eth1
iface eth1 inet static
    address 10.1.0.10
    netmask 255.255.0.0
    network 10.1.0.0
    broadcast 10.1.255.255

# Private network (OpenStack)
auto eth2
iface eth2 inet static
    address 10.2.0.10
    netmask 255.255.0.0
    network 10.2.0.0
    broadcast 10.2.255.255

当我检查接口配置时,IPv6 已启用:

$ sudo ifconfig
[sudo] password for openstack: 
eth0      Link encap:Ethernet  HWaddr 08:00:27:6f:c5:38  
          inet addr:172.16.1.23  Bcast:172.31.255.255  Mask:255.240.0.0
          inet6 addr: fe80::a00:27ff:fe6f:c538/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:614 errors:0 dropped:0 overruns:0 frame:0
          TX packets:120 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:61279 (59.8 KiB)  TX bytes:13336 (13.0 KiB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:79:99:40  
          inet addr:10.1.0.10  Bcast:10.1.255.255  Mask:255.255.0.0
          inet6 addr: fe80::a00:27ff:fe79:9940/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:35 errors:0 dropped:0 overruns:0 frame:0
          TX packets:55 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:5288 (5.1 KiB)  TX bytes:8485 (8.2 KiB)

eth2      Link encap:Ethernet  HWaddr 08:00:27:f1:7b:f5  
          inet addr:10.2.0.10  Bcast:10.2.255.255  Mask:255.255.0.0
          inet6 addr: fe80::a00:27ff:fef1:7bf5/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:35 errors:0 dropped:0 overruns:0 frame:0
          TX packets:55 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:5288 (5.1 KiB)  TX bytes:8690 (8.4 KiB)

man 5 interfaces不讨论如何在接口上禁用 IPv6。Debian IPv6 项目没有指定如何禁用 Wheezy 的 IPv6(仅限 Squeeze 的内核级别)。

由于缺乏文档,我尝试在 and 中添加and ,off但导致错误:disableeth1eth2

iface eth1 inet6 off

(显然,上述节完全破坏了网络,因为我没有得到任何结果ifconfig并且ping无法工作。此外,即使没有修改,和也处于关闭状态。eth0lo

我应该添加什么/etc/network/interfaces来禁用我已配置的接口上的 IPv6?

答案1

根据这个答案,下面/etc/sysctl.conf应该在所有接口上禁用 IPv6:

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

编辑:对于只有一个接口,以下内容应该可以解决问题(替换<interface>为接口的名称):

net.ipv6.conf.<interface>.disable_ipv6 = 1

相关内容