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.
Method 1
Edit File/etc/sysctl.conf,
Vi/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.
Sysctl-p
Method 2
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/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.
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:
#AddressFamily any
Change it to:
AddressFamily inet
Or, remove the comment (#) in front of the line:
#ListenAddress 0.0.0.0
Then restart SSH for the change to take effect.
Systemctl Restart sshd
Question 2:
If you are having trouble starting postfix after you disable Ipv6, edit/etc/postfix/main.cf:
Vi/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 . ~
Free pick up Brother Lian IT Education Original Linux Operations Engineer video/Detailed Linux tutorials, details of the website customer service: http://www.lampbrother.net/linux/
or hooking up with Q2430675018.
Welcome to the Linux Communication Group 142986065
How to disable IPv6 in CentOS 7