玩蛇网提供最新Python编程技术信息以及Python资源下载!
您现在的位置: 玩蛇网首页 > linux入门教程 > 正文内容

IPv6协议关闭方法基于linux的操作

玩蛇网推荐图文教程:python 列表

IPv6协议关闭方法基于linux操作,具体关于在Linux禁用IPv6的方法,大家可以使用下面介绍的几种方式来进行尝试性的修改操作:

第一种方式:
在/etc/modprobe.d/dist.conf文件中添加install ipv6 /bin/true,在reboot后使用使用lsmod | grep ipv6查看,IPv6模块没有被加载,在/proc/sys/net目录下也已经没有了ipv6的目录文件。

[root@root net]# ls
core  ipv4  netfilter  unix

第二种方式:
在/boot/grub/grub.conf文件中,在启动的Linux内核版本中传递下面的参数ipv6.disable=1,该效果和方式一基本类似,都需要重新启动,但是在启动完成后,使用lsmod还是可以参看到ipv6模块信息,但引用ipv6模块数为0. 在/proc/sys/net目录下也没有了ipv6的目录文件。
[root@root~]# lsmod | grep ipv6

ipv6                  331149  0

 上面这种方式其实是根据IPv6模块的三个参数进行的,通过modinfo可以看到,IPv6模块支持三个参数:

modinfo ipv6

filename:      /lib/modules/2.6.32/kernel/net/ipv6/ipv6.ko

alias:          net-pf-10

license:        GPL

description:    IPv6 protocol stack for Linux

author:        Cast of dozens

srcversion:    AA5735202A5094F448BF9AE

depends:       

vermagic:      2.6.32 SMP mod_unload modversions 

parm:          disable:Disable IPv6 module such that it is non-functional (int)

parm:          disable_ipv6:Disable IPv6 on all interfaces (int)

parm:          autoconf:Enable IPv6 address autoconfiguration on all interfaces (int)

大家可以在Linux内核文档中找到以下的这个三个参数的解释:

disable

        Specifies whether to load the IPv6 module, but disable all

        its functionality.  This might be used when another module

        has a dependency on the IPv6 module being loaded, but no

        IPv6 addresses or operations are desired.

        The possible values and their effects are:

        0 IPv6 is enabled.

                  This is the default value.

        1 IPv6 is disabled.

                  No IPv6 addresses will be added to interfaces, and

                  it will not be possible to open an IPv6 socket.

                  A reboot is required to enable IPv6.

autoconf

        Specifies whether to enable IPv6 address autoconfiguration

        on all interfaces.  This might be used when one does not wish

        for addresses to be automatically generated from prefixes

        received in Router Advertisements.

        The possible values and their effects are:

        0 IPv6 address autoconfiguration is disabled on all interfaces.

                  Only the IPv6 loopback address (::1) and link-local addresses

                  will be added to interfaces.

        1 IPv6 address autoconfiguration is enabled on all interfaces.

                  This is the default value.

disable_ipv6

        Specifies whether to disable IPv6 on all interfaces.

        This might be used when no IPv6 addresses are desired.

        The possible values and their effects are:

        0 IPv6 is enabled on all interfaces.

                  This is the default value.

        1 IPv6 is disabled on all interfaces.

                  No IPv6 addresses will be added to interfaces.

        在grub.conf中还可以使用ipv6.disable_ipv6=1禁止IPv6协议,和ipv6.disable不同的是对IPv6模块的引用不为零。

lsmod | grep ipv6

ipv6                  331934  30

使用echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6 命令可以把IPv6功能重新打开,使用echo 0 > /sys/module/ipv6/parameters/disable_ipv6命令无法重新打开,这也是这两个控制IPv6协议开关的不同之处。

即使在grub.conf文件中不添加ipv6的任何信息,向/sys/module/ipv6/parameters/disable_ipv6文件中写入也不能控制IPv6协议,建议使用proc目录下的变量控制。

IPv6协议关闭方法基于linux的操作,第三种方式:在/proc/sys/net/ipv6/conf/目录下有下面的目录

[root@root conf]# ls

all  default  eth0  gre0  lo

        可以针对不同的接口禁止,如果是针对所有的接口,可以使用下面的命令,该命令会直接把接口上的IPv6地址给删掉,包括本地链路地址fe80::,

IPv6, net.ipv6.conf.all.disable_ipv6 = 1

net.ipv6.conf.default.disable_ipv6 = 1

        下面是Linux内核对该参数的解释:

disable_ipv6 - BOOLEAN Disable IPv6 operation.  If accept_dad is set to 2, this value

        will be dynamically set to TRUE if DAD fails for the link-local

        address.

        Default: FALSE (enable IPv6 operation)

        When this value is changed from 1 to 0 (IPv6 is being enabled),

        it will dynamically create a link-local address on the given

        interface and start Duplicate Address Detection, if necessary.

        When this value is changed from 0 to 1 (IPv6 is being disabled),

        it will dynamically delete all address on the given interface

 

玩蛇网文章,转载请注明出处和文章网址:http://www.iplaypy.com/linux/l6570.html

相关文章 Recommend

玩蛇网Python互助QQ群,欢迎加入-->: 106381465 玩蛇网Python新手群
出炉日期:2017-02-28 14:40 玩蛇网 www.iplaypy.com

我要分享到:

必知PYTHON教程 Must Know PYTHON Tutorials

必知PYTHON模块 Must Know PYTHON Modules