Turn OFF IPv6

From Manjaro Linux
Jump to: navigation, search
The following works for both systemd & OpenRC.
neognomic Wanted a warning put into this page, so:-

It is apparently possible to find software that is IPv6 centric
& may have a problem if IPv6 is turned off. I have no idea what
software that is so I can't warn you about that - so there you go.

Of course if you do manage to find a way to have any kind of problem
after turning IPv6 off, then please, turn it back on again... You
could also post in the Manjaro forum about it, as well as do some
investigating over at the ArchWiki/Forum & elsewhere on the web.

Introduction

For anyone who has any kind of problems with IPv6, this page will show how to turn it off at the kernel level. Our (Arch/Manjaro) kernels have IPv6 built in so we can't just blacklist the IPv6 module. Instead we can pass an argument to the kernel via the /etc/default/grub kernel line.


How to tell the kernel that we don't want IPv6

You turn off the entire IPv6 stack by adding the following; ipv6.disable=1 to your /etc/defaults/grub file's kernel line like so (its the 4th line down in my file):

GRUB_CMDLINE_LINUX_DEFAULT=" ipv6.disable=1 "

(If you have any other parameters in your line leave them where they are, just add the ipv6.disable=1 command at the beginning of the line - after the first double quote " .)

Here's another option that may be suitable for your situation, it is used exactly the same as in the above example:

ipv6.disable_ipv6=1 keeps the IPv6 stack but assigns NO IPv6 IP addresses to any of your network devices.


Edit out IPv6 in /etc/hosts

Then in your /etc/hosts file comment out the following line by putting a # at the beginning of the following line (there are variations of this line, here are a couple of them):

# ::1		localhost.localdomain	localhost
# ::1	localhost ip6-localhost ip6-loopback


Generate a new /boot/grub/grub.cfg

After you have done those two things you then need to generate a new grub.cfg by using the following command at the terminal prompt:

sudo grub-mkconfig -o /boot/grub/grub.cfg

That's it, the next time you boot up your machine you will have no IPv6 . Which is certainly the way I prefer things to be.


Check your system to see if IPv6 is on/off

For those that feel the need to check on their work, following are a few ways to check if IPv6 has been turned off or not. The first (easiest) & the last are done via your browser & rely on many unknown & uncontrollable variables that the wonderful world of the web provides for us. The second option requires you to copy & past a command string into your terminal & run it. This tests your machine & as it relies on no other machines or networks it has to be the most reliable method of testing out of the three below:

Check if IPv6 is working at http://test-ipv6.com

This is an easy test run by entering the following URL in your browser's location field - http://test-ipv6.com

A command string to be entered into the terminal

 test -f /proc/net/if_inet6 && echo "IPv6 supported" || echo "IPv6 not supported"

The above string run from your terminal will display a result of IPv6 supported OR IPv6 not supported in your terminal after it is run, the result depends on whether the file /proc/net/if_intet6 exists on your system or not.

The easiest way to use the above string is to just copy & paste it to the terminal & hit Enter.

If you have a need for some reason to be switching IPv6 on/off you could make a function for your ~/.bashrc or use the following simple script. Copy & paste it into a text editor, save it as any name you like & then make it executable by issuing the following command in the terminal, or if your file manager or desktop provides a GUI method to make the file executable, then you could use that method:

chmod 751 [file.name]

Then copy it into /usr/bin (or somewhere else on your system's search path).

The little script file:

#!/bin/bash

## Script that echo's a test for whether IPv6 is turned on/off on your system:

echo
echo -e " \e[0;33m Copy, paste to terminal prompt & run - the following line to check if IPv6 is turned on/off: \033[0m"
echo
echo -e 'test -f /proc/net/if_inet6 && echo "\e[0;32mIPv6 supported\e[0m" ||  echo "\e[0;31mIPv6 not supported\e[0m"'
echo

After that just type the file's name (that you gave it) into the terminal then copy & paste the string from the terminal back to the terminal prompt & it will either run automatically or you will have to hit Enter to get it to spit out its finding re. your system & IPv6. All in the interest of making life easier for our poor overworked memories.

Run a number of checks at https://ipleak.net

In the early section of the page you will either see the results of the IPv6 test, or you will be able to read IPv6 test not reachable. Obviously if you see IPv6 test not reachable that indicates that your IPv6 is turned off.


Other reference

The ArchWiki as usual has a much more in depth page than this one. This page is one that is intentionally simplified & topic specific, with the sole purpose of helping those that are relatively new to Linux (this is of course the major purpose of most of the pages that exist in the Manjaro Wiki).

If you have an unusual usage situation, strange hardware or for whatever reason you have found that your system does have a problem due to your having turned IPv6 off - go & have a look at this ArchWiki page: [1] Posting in this page's Support forum (link below) may also be of help too.

Support

Following is a link to this page's forum counterpart where you can post any related feedback: [2]