在Debian Wheezy中禁用接口上的IPv6?


10

我正在研究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的项目没有规定如何禁用IPv6的喘息(仅内核级的挤压)。

在没有文件的,我想加入off,并disableeth1eth2,但它导致错误:

iface eth1 inet6 off

(显然,上面的节完全断开了网络连接,因为我什么也没用,ifconfig并且ping无法正常工作。此外,即使未进行任何修改,它eth0lo都处于关闭状态。)

我要添加什么/etc/network/interfaces以在已配置的接口上禁用IPv6?



谢谢迈克尔。它接近,但不完全相同。我正在为我配置的接口而不是内核禁用它。
jww 2013年

2
如果您对阻止IPv6(不禁用)感到满意,那么可以使用它ip6tables来完全阻止IPv6的输入和输出,但是接口仍将侦听IPv6。
VL-80

另一个可能的解决方案:根据Linux IPv6 HOWTO,可以使用command删除IPv6地址# /sbin/ifconfig <interface> inet6 del <ipv6address>/<prefixlength>。我在内核中禁用了IPv6,因此无法对其进行测试。无论如何,请尝试并让我们知道。
VL-80

1
谢谢迈克尔。“为什么要尝试在接口上禁用IPv6”-我的小实验室仅提供IPv4,因此不需要IPv6。IP v6使用其他资源并增加了攻击面。另外,它会在接线过程中产生大量噪声。我想我可以网上抽空:为什么人们会经营他们不需要或不需要的东西?
jww 2013年

Answers:


13

根据此答案,以下命令/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

sudo sysctl -p进行上述更改后,您可能需要运行。(或者,您也可以重新启动。)
mpb
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.