How to Really Disable IPv6 on Raspberry PI

Oh, I know, I know. Internet Protocol version 6 is the future and the answer to my dreams. Why would I ever want to shut it off?!? I know, right? I’ve heard it all before! My ISP still doesn’t even offer it. Whatever. Nobody uses it and it just creates a lot of chatter on my intranet that literally serves no purpose! I mean, look at the protocol analysis that I see on my pi-hole:

What’s the salmon colored region? A third of my traffic? No thanks! Let’s shut this off!

Method 1:

To disable ipv6, you have to open /etc/sysctl.conf using any text editor and insert the following lines at the end:

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

and reboot. If IPv6 is still not disabled, then the problem is that sysctl.conf is still not activated. To solve this, type the command:

sudo sysctl -p

You will see this in the terminal:

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

After that, if you run:

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

If you see 1, ipv6 has been successfully disabled.

Method 2:

Change to the /boot directory. If you’re logged in to your raspberry, you can:

cd /boot

If you still have the SDcard in your PC, the /boot partition is the one that’s visible on the card. Use notepad.exe to edit cmdline.txt. In LINUX, you need to edit /boot/cmdline.txt as follows:

root@salt# vi /boot/cmdline.txt
console=serial0,115200 console=tty1 root=/dev/sda1 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles

now just add ” ipv6.disable=1″ to the end of the line, so it looks something like this:

console=serial0,115200 console=tty1 root=/dev/sda1 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles ipv6.disable=1

Now, save the file and reboot.

Here’s my ifconfig before the change:

root@salt:/srv/salt# ifconfig
eth0: flags=4163 mtu 1500
inet 10.0.0.109 netmask 255.255.255.0 broadcast 10.0.0.255
inet6 fe80::4bb9:ba93:5b15:361c prefixlen 64 scopeid 0x20
ether dc:a6:32:6c:2e:1c txqueuelen 1000 (Ethernet)
RX packets 29516 bytes 2980054 (2.8 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 10356 bytes 824377 (805.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

and here it is after:

root@salt:~# ifconfig
eth0: flags=4163 mtu 1500
inet 10.0.0.109 netmask 255.255.255.0 broadcast 10.0.0.255
ether dc:a6:32:6c:2e:1c txqueuelen 1000 (Ethernet)
RX packets 72 bytes 10477 (10.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 56 bytes 7408 (7.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

No more IPv6!

Author: John

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.