Linux configuration Disable Enable IPv6

Source: Internet
Author: User
Tags memcached dovecot

IPV6 is considered an alternative to IPv4, which is used to address the impending exhaustion of existing IPv4 address spaces.
But for now, opening IPv6 may cause some problems. So sometimes we need to close IPv6.
Here's how the IPv6 shutdown method should work for all major Linux distributions including Ubuntu, Debian, and CentOS.

IPV6 is enabled by default in the CentOS6.5 system and can confirm the status of IPV6 in the following ways

1.1. View the enabled state of the system IPV6

The following command returns a value of 0 for IPV6 enabled and 1 for disabling

cat /proc/sys/net/ipv6/conf/all/disable_ipv6cat /proc/sys/net/ipv6/conf/default/ Disable_ipv6
Ifconfig-ANPTL
1.2. View Kernel module calls

# There is a return result, stating that the IPV6 module is enabled, it can be seen that those programs have been called, and otherwise not enabled

Lsmod grep IPv6
2. Disable IPv62.1. Temporarily disable IPV6

# command line to adjust kernel parameters, temporarily disable IPV6

Echo 1 >/proc/sys/net/ipv6/conf/all/disable_ipv6echo1 >/proc/sys/net/ipv6/ conf/default/-w net.ipv6.conf.all.disable_ipv6=1-w net.ipv6.conf.default.disable_ipv6=1
2.2. Permanently disable IPV6
Echo " ">>/etc/sysctl.confEcho "# made for disabled IPv6 in $ (date +%f)">>/etc/sysctl.confEcho 'Net.ipv6.conf.all.disable_ipv6 = 1'>>/etc/sysctl.confEcho 'Net.ipv6.conf.default.disable_ipv6 = 1'>>/etc/sysctl.confEcho 'Net.ipv6.conf.lo.disable_ipv6 = 1'>>/etc/sysctl.confTail-5/etc/Sysctl.confsysctl-Pnetstat-anptl

You can also edit the system kernel configuration file directly

vim/etc/sysctl.conf------------------------------------------------------ for  111-------------------------------------------------------

# If you want to disable IPV6 for a particular NIC, such as eth1, add the following line instead.

1

# Note Check Modify the IPV6 configuration in the network configuration file

Vim/etc/sysconfig/network--------------------------------------networking_ipv6= No--------------------------------------

# Note Modify Ifcfg-eth0

vim/etc/sysconfig/network-scripts/ifcfg-eth0----------------------------------ipv6init=  No----------------------------------
2.3. Extension: Disabling IPV6 may cause some services to fail to start

1) Modify SSH configuration, only listen to IPV4 address

vim/etc/ssh/sshd_config----------------------------------------0.0. 0.0 addressfamily inet-----------------------------------------ANPTL

Note: INET is supported only for IPV4,INET6 for Ipv6,any only

2) MySQL configuration issues

After MySQL installs the default listens to the IPV6 address, after closes IPv6, needs to edit, in [mysqld] adds

vim/etc/my.cnf----------------------------------------bind-address=0.0. 0.0----------------------------------------

After modifying the restart MySQL can be

3) Configure Redis, monitor IPV4 address

Vim  /usr/local/redis/conf/redis.conf----------------------------------------127.0 . 0.1----------------------------------------

4) Configure memcached, monitor IPV4 address

# Configure memcached, listen to address requires IP, use localhost cannot start memcached

# memcached 12001 127.0. 0.1 -d-p/tmp/memcached1.pid

5) Configuration Vsftp

vim/etc/vsftpd/vsftpd.conf----------------------------------------Listen=Yeslisten_ipv6 =NO----------------------------------------

6) Configure Postfix monitor IPV4 address

vim/etc/postfix/main.cf----------------------------------------127.0. 0.1----------------------------------------

7) Configure Dovecot Monitor IPV4 address

vim/etc/dovecot/dovecot.conf----------------*----------------

8) Configuration xinetd

/etc/------------------------bind            0.0.  0.0------------------------# reload config file service xinetd reload

These are the programs that may be affected after disabling IPv6, and can be configured according to your actual situation.

3. Configure enable IPv63.1. View the IPV6 status of the Linux system
cat /proc/sys/net/ipv6/conf/all/disable_ipv6cat /proc/sys/net/ipv6/conf/default/ Disable_ipv6
3.2. Adjust kernel parameters to enable IPV6 immediately
Echo 0 >/proc/sys/net/ipv6/conf/all/disable_ipv6echo0 >/proc/sys/net/ipv6/ conf/default/-w net.ipv6.conf.all.disable_ipv6=0-w net.ipv6.conf.default.disable_ipv6=0

The revision is temporary, restart the aging

3.3. Modify kernel parameters, enable IPV6 configuration
vim/etc/sysctl.conf----------------------------------------------00 0-----------------------------------------------P  
3.4. Manually call the system IPv6 kernel
modprobe IPv6
3.5. Error Handling
modprobe ipv6fatal:module off not found.

Reason for failure: IPV6 module is not enabled

Workaround:
Need to edit configuration file, enable IPV6 kernel module, cannot call IPv6 module in disabled state
This process requires a reboot of the system, and the IPv6 module automatically calls after startup

vim/etc/modprobe. d/--------------------------------#alias net-pf-  off# Alias IPv6 offoptions ipv6 disable=0---------------------------------lsmod | grep ipv6                      IPv6                  335781  

Finished, hehe hehe

Linux configuration Disable Enable IPv6

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.