How to disable IPv6 in Linux Kernel

Source: Internet
Author: User
Tags linux mint

How to disable IPv6 in Linux Kernel

To disable IPv6 in Linux, you can use the following methods:

Method 1:

In/etc/modprobe. d/dist. add install ipv6/bin/true to the conf file, and use lsmod | grep ipv6 After reboot. The IPv6 module is not loaded, ipv6 directory files are also unavailable in the/proc/sys/net directory. [Root @ root net] # ls

Core ipv4 netfilter unix

Method 2:

In/boot/grub. in the conf file, in the Linux kernel version that is started, pass the following parameter named restart 6.disable = 1. The effect is similar to that of method 1. You must restart the system. However, after the startup is complete, you can still see the ipv6 module information using lsmod, but the number of referenced ipv6 modules is 0. there is no ipv6 directory file in the/proc/sys/net directory.

[Root @ root ~] # Lsmod | grep ipv6

Ipv6 331149 0

The above method is based on the three parameters of the IPv6 module. You can see through modinfo that the IPv6 module supports three parameters,

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)

In the Linux kernel documentation, we can see the explanation of the three parameters:

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 ses sses 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

Specified ed 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.

In grub. conf, you can also use ipv6.disable _ ipv6 = 1 to disable the IPv6 protocol. Unlike ipv6.disable, the reference to the IPv6 module is not zero.

Lsmod | grep ipv6

Ipv6 331934 30

You can use the echo 0>/proc/sys/net/ipv6/conf/all/disable_ipv6 command to re-open the IPv6 function,

The echo 0>/sys/module/ipv6/parameters/disable_ipv6 command cannot be re-opened, which is also the difference between the two control IPv6 protocol switches. Even in grub. no ipv6 information is added to the conf file. writing to the/sys/module/ipv6/parameters/disable_ipv6 file cannot control the IPv6 protocol. We recommend that you use variable control in the proc directory.

Method 3:

The following directory is available under the/proc/sys/net/ipv6/conf/directory:

[Root @ root conf] # ls

All default eth0 gre0 lo

It can be disabled for different interfaces. If it is for all interfaces, you can use the following command to directly Delete the IPv6 address on the interface, including the local link address fe80: :,

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

Net. ipv6.conf. default. disable_ipv6 = 1

The Linux kernel explains this parameter as follows:

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


Appendix: module parameter definition

Module_param_named (disable_ipv6, ipv6_defaults.disable_ipv6, int, 0444 );

MODULE_PARM_DESC (disable_ipv6, "Disable IPv6 on all interfaces ")

Only IPv6 module parameters are used in the addrconf_init_net function. Therefore, the disable_ipv6 parameter of the IPv6 module is assigned only during initialization, and the original configuration cannot be changed after the system is started.

Static int addrconf_init_net (struct net * net)

{

Int err;

Struct defaults 6_devconf * all, * dflt;

 

Err =-ENOMEM;

All = & ipv6_devconf;

Dflt = & pai6_devconf_dflt;

 

If (net! = & Init_net ){

All = kmemdup (all, sizeof (ipv6_devconf), GFP_KERNEL );

If (all = NULL)

Goto err_alloc_all;

 

Dflt = kmemdup (dflt, sizeof (%6_devconf_dflt), GFP_KERNEL );

If (dflt = NULL)

Goto err_alloc_dflt;

} Else {

/* These will be inherited by all namespaces */

Dflt-> autoconf = ipv6_defaults.autoconf;

Dflt-> disable_ipv6 = ipv6_defaults.disable_ipv6;

}

 

Net-> ipv6.devconf _ all = all;

Net-> ipv6.devconf _ dflt = dflt;

 

# Ifdef CONFIG_SYSCTL

Err = _ addrconf_sysctl_register (net, "all", NET_PROTO_CONF_ALL,

NULL, all );

If (err <0)

Goto err_reg_all;

 

Err = _ addrconf_sysctl_register (net, "default", NET_PROTO_CONF_DEFAULT,

NULL, dflt );

If (err <0)

Goto err_reg_dflt;

# Endif

Return 0;

 

# Ifdef CONFIG_SYSCTL

Err_reg_dflt:

_ Addrconf_sysctl_unregister (all );

Err_reg_all:

Kfree (dflt );

# Endif

Err_alloc_dflt:

Kfree (all );

Err_alloc_all:

Return err;

}

Enable IPV6 in Ubuntu

IPV6 address for Cisco CCIE Certification knowledge points

How to capture IPV6 data packets in WireShark

Use IPV6 source for traffic-free updates on Ubuntu 12.04 Campus Network

Build an IPV6 ftp server in Linux

CentOS IPV6 settings

Set Update source in CentOS pure IPV6 environment

How to disable CentOS 6 IPV6

How to disable IPv6 on Ubuntu, Linux Mint, and Debian

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.