How to disable IPv6 in CentOS 7
Https://Linux.cn/article-4935-1.html
Recently, a friend of mine asked me how I should prohibit IPv6. After searching for a few, I found the following scenario. Here's how to disable IPv6 on my CentOS 7 mini-server.
You can do this in two ways.
Edit File/etc/sysctl.conf,
Add the following line:
-
- NET. IPv6. Conf. All. Disable_ipv6 = 1
-
- 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.
- NET. IPv6. Conf. Enp0s3. Disable_ipv6 = 1
Save and exit the file.
Execute the following command to make the setting effective.
To disable IPV6 in a running system, enter the following command:
- echo 1 > /proc/sys/net/ipv6 /conf/all/disable_ipv6
- echo 1 > /proc/sys/net/ipv6 /conf/default/< Span class= "PLN" style= "color: #b8ffb8" >disable_ipv6
or,
- sysctl-w Net.ipv6.conf. All. Disable_ipv6=1
- sysctl -w Net.ipv6.conf. Default. Disable_ipv6=1
That's it. Now the IPV6 has been banned.
You may have some problems after banning IPv6.
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:
Change it to:
Or, remove the comment (#) in front of the line:
Then restart SSH for the change to take effect.
If you are having trouble starting postfix after you disable Ipv6, edit/ETC/POSTFIX/MAIN.CF:
Comment out the localhost part of the configuration and use the IPv4 loopback.
- #inet_ Interfaces = localhost
- inet_interfaces = 127.0. 0.1
That's it, cheers!
CentOS 7 Forbidden IPv6