CentOS7 Disable IPv6

Source: Internet
Author: User

CentOS7 Disable IPv6

Recently, a friend of mine asked me how to disable IPv6. After searching, I found the following solution. The following describes how to disable IPv6 on my CentOS 7 mini server.

You can do this in two ways.

Method 1

Edit the/etc/sysctl. conf file,

 
  1. Vi/etc/sysctl. conf

Add the following rows:

 
  1. Net. ipv6.conf. all. disable_ipv6 = 1
  2. Net. ipv6.conf. default. disable_ipv6 = 1

If you want to disable IPv6. for example, for enp0s3, add the following line.

 
  1. Net. ipv6.conf. enp0s3. disable_ipv6 = 1

Save and exit the file.

Run the following command to make the settings take effect.

 
  1. Sysctl-p
Method 2

To disable IPv6 in the running system, enter the following commands in sequence:

 
  1. Echo 1>/proc/sys/net/ipv6/conf/all/disable_ipv6
  2. Echo 1>/proc/sys/net/ipv6/conf/default/disable_ipv6

Or,

 
  1. Sysctl-w net. ipv6.conf. all. disable_ipv6 = 1
  2. Sysctl-w net. ipv6.conf. default. disable_ipv6 = 1

That's it. IPv6 is now disabled.

What should I do if I have problems disabling IPv6?

You may encounter some problems after disabling IPv6.

Question 1:

If you encounter issues with SSH after disabling IPv6, follow the steps below.

Edit the/etc/ssh/sshd_config file

Vi/etc/ssh/sshd_config

Find the following line:

 
  1. # AddressFamily any

Change it:

 
  1. AddressFamily inet

Or, remove the comment (#) before this line (#):

 
  1. # ListenAddress 0.0.0.0

Restart ssh to make the change take effect.

 
  1. Systemctl restart sshd
Question 2:

If you encounter a problem when starting postfix after disabling Ipv6, edit/etc/postfix/main. cf:

 
  1. Vi/etc/postfix/main. cf

Comment out the localhost section in the configuration and use ipv4 loopback.

#inet_interfaces = localhostiet_interfaces = 127.0.0.1

That's it. Cheers!

Via: http://www.unixmen.com/disable-ipv6-centos-7/

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.