Disable ipv6 on Linux
There are several ways to do disable ipv6, here I show few of the ones I know available
Check if ipv6 is kernel read
test -f /proc/net/if_inet6 && echo "Running kernel is IPv6 ready"
Check if ipv6 is enable system wide
[ "$(sysctl -n net.ipv6.conf.all.disable_ipv6)" -eq 0 ] \
&& echo "IPv6 enabled system-wide" \
|| echo "IPv6 disabled system-wide"
Edit sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
- Apply Changes: Run
sysctl -pto load the new settings
Grub
Edit GRUB: Open /etc/default/grub and find the GRUB_CMDLINE_LINUX_DEFAULT line
GRUB_CMDLINE_LINUX="ipv6.disable=1"
Update grub
grub-mkconfig -o /boot/grub/grub.cfg
Temporary disable ipv6 for current session
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
- Enable above settings temporary by type
sysctl -p
Permanent disable ipv6 in /etc/systctl.conf
cat <<EOF > /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
EOF;sysctl -p