How to disable IPv6 in CentOS 7

Source: Internet
Author: User
Tags linux mint

How to disable IPv6 in CentOS 7

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.

  1. # Inet_interfaces = localhost
  2. Inet_interfaces = 127.0.0.1

That's it. Cheers!

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

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.