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,
- 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 = localhost
- 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