How to disable IPv6 in CentOS 7

Source: Internet
Author: User

Recently, a friend of mine asked me how to disable IPv6. After searching for a few, I found the following scenario. Here's how to turn off IPv6 on my CentOS 7 mini-server.

You can do this in two ways.

Method 1

Edit File /etc/sysctl.conf,

    1. VI /etc/sysctl. conf

Add the following line:

    1. NET. IPv6. Conf. All. Disable_ipv6 =1
    2. NET. IPv6. Conf. Default. Disable_ipv6 =1

If you want to disable IPV6 for a particular NIC, for example, for ENP0S3, add the following line.

    1. NET. IPv6. Conf. Enp0s3. Disable_ipv6 =1

Save and exit the file.

Execute the following command to make the setting effective.

    1. Sysctl -p
Method 2

To disable IPV6 in a running system, enter the following command:

    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. Now the IPV6 has been banned.

What do I do if I have problems after banning IPv6?

You may have some problems after banning IPv6.

Question 1:

If you are having problems with SSH after you disable IPV6, follow the instructions below.

Edit /etc/ssh/sshd_config file

Vi/etc/ssh/sshd_config

Locate the following line:

    1. #AddressFamily any

Change it to:

    1. AddressFamily inet

Or, remove the comment (#)in front of the line:

    1. #ListenAddress 0.0.0.0

Then restart SSH for the change to take effect.

    1. Systemctl Restart sshd
Question 2:

If you are having trouble starting postfix after you disable Ipv6, edit /etc/postfix/main.cf:

    1. VI /etc/postfix/main. CF

Comment out the localhost part of the configuration and use the IPv4 loopback.

    1. #inet_interfaces = localhost
    2. Inet_interfaces =127.0. 0.1

How to disable IPv6 in CentOS 7

Related Article

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.