LLI Wiki — My Digital Knowledge Base

Disable and enable IPv6 on Linux

Disable IPv6 at runtime through /proc for one or all interfaces, and how IPv4-mapped listening behaves.

IPv6 can be turned off or back on for each network interface at runtime, through the disable_ipv6 entries under /proc/sys/net/ipv6/conf/. A change made this way does not survive a reboot (see Notes).

Disable or enable IPv6 on one interface

sudo sh -c 'echo 1 > /proc/sys/net/ipv6/conf/enp0s3/disable_ipv6'   # disable
sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/enp0s3/disable_ipv6'   # enable

The sh -c wrapper is required: a plain sudo echo 1 > file performs the redirection in the calling shell, which is not root.

Disable IPv6 on all interfaces

sudo sh -c 'echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6'
Path Scope
conf/all/disable_ipv6 every interface
conf/<interface>/disable_ipv6 one interface (for example enp0s3 or eth0)

How sockets use IPv6 (ipv6(7))

Notes

Mastodon LLIMastodon SocialFosstodon