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 running on a Raspberry Pi:

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!

3 thoughts on “How to Really Disable IPv6 on Raspberry PI

  1. For anyone coming along after me, Method 1 doesn’t necessarily work. You should instead take the three lines above and put them into a unique file under the /etc/sysctl.d/ folder. The /etc/sysctl.conf file is supposed to be symlinked to /etc/sysctl.d/99-sysctl.conf, but it doesn’t always seem to be the case. Caused me a few head scratches. Anyway, you shouldn’t be modifying either file, and should instead create your own to be safe.

  2. Much appreciated Ryan. Looking at the README in the /etc/sysctl.d folder tells us that, as well, and suggests just using a file called local.conf in there with whatever local changes you make.

  3. thats great and all, but when i did this on a pikvm, the UI webpage that you would login to become unavailable, the moment you removed the ipv6.disable=1 from the cmdline.txt the UI was accessible again, with the ipv6.disable=1 in place you could ping it by name or IP, but you could not get the webpage UI (that provides you the login to view the connected computer). removing that ipv6.disable=1 allowed access to the UI, but it also showed inet6 address running ifconfig, so ipv6 could never be disabled.

Leave a Reply to Bryan Burroughs Cancel 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.