How to Disable IPv6 on Linux

Posted on In Linux, Network

IPv6 is enabled by default on most Linux distros. However, IPv6 is not used for some situations for most of time and it may cause troubles and requires effort to protect the network and ensure the security. This post introduces how to disable IPv6 support on Linux (newer modern Kernel versions).

First, add these lines to /etc/sysctl.conf:

net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1

IPv6 on Linux can be easily configured via sysctrl. To make it take effect, run as root:

sysctl -p

To verify, check the network interfaces whether IPv6 addresses disappear by ifconfig.

You may also check that the kernel variable contains 1:

cat /proc/sys/net/ipv6/conf/all/disable_ipv6

The settings are in sysctl.conf and after restarts, Linux will load them and the settings will still take effect.

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

2 comments

  1. Nice try, but the correct config parameters are:

    net.ipv6.conf.all.disable_ipv6=1
    net.ipv6.conf.default.disable_ipv6=1

    between disable and ipv6 you have to paste an underscore

    1. Thanks for pointing this out. It is a formatting problem after the site changes to be using markdown. `_` is treated as a formatting character. It is fixed now.

Leave a Reply

Your email address will not be published. Required fields are marked *