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,
- Vi/etc/sysctl. conf
Add the following rows:
- Net. ipv6.conf. all. disable_ipv6 = 1
- Net. ipv6.conf. default. disable_ipv6 = 1
If you want to disable IPv6. for example, for enp0s3, add the following line.
- Net. ipv6.conf. enp0s3. disable_ipv6 = 1
Save and exit the file.
Run the following command to make the settings take effect.
- Sysctl-p
Method 2
To disable IPv6 in the running system, enter the following commands in sequence:
- 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. 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:
- # AddressFamily any
Change it:
- AddressFamily inet
Or, remove the comment (#) before this line (#):
- # ListenAddress 0.0.0.0
Restart ssh to make the change take effect.
- Systemctl restart sshd
Question 2:
If you encounter a problem when starting postfix after disabling Ipv6, edit/etc/postfix/main. cf:
- 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/