nbalonso.com

Disable IPv6 on Fedora 20

| Comments

With most of the important linux distributions making the move to systemd you might be asking how can you manage the services and features that your computer enables during boot?. Disabling IPv6 on a Fedora 20 is an easy way to learn the new method of doing things with systemd.

There is a magic tool for configuring kernel parameters which is sysctl.

In your Fedora box you will find a detailed man page on how to use this tool, but if you want to have a look at a simpler version check this one out.

Now which options do we have and which are their current settings? Let’s list all the current variables and filter them for this ipv6 example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
bash-3.2$ sysctl -a | grep ipv6 | less
net.ipv6.bindv6only = 0
net.ipv6.conf.all.accept_dad = 1
net.ipv6.conf.all.accept_ra = 1
net.ipv6.conf.all.accept_ra_defrtr = 1
net.ipv6.conf.all.accept_ra_pinfo = 1
net.ipv6.conf.all.accept_ra_rt_info_max_plen = 0
net.ipv6.conf.all.accept_ra_rtr_pref = 1
net.ipv6.conf.all.accept_redirects = 1
net.ipv6.conf.all.accept_source_route = 0
net.ipv6.conf.all.autoconf = 1
net.ipv6.conf.all.dad_transmits = 1
net.ipv6.conf.all.disable_ipv6 = 0
...

The last line shown here is exactly what we wanted to change. As you might have guessed 0 is false and 1 is true, so here ipv6 is enabled (which is the default)

I found two methods for doing the change:

  • The easiest ways is to set the value with sysctl itself:
1
bash-3.2$ su -c "sysctl -w net.ipv6.conf.all.disable_ipv6=1"
  • The second and a bit longer way is to write the change to /etc/sysctl.conf and then ask sysctl to read the config file. You can do it with:
1
2
bash-3.2$ su -c 'echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf'
bash-3.2$ su -c 'sysctl -p'

The second way is a bit longer but it keeps everything documented in one place and changes are more likely to survive future kernel upgrades. So if you can choose, do the second one be a happy sysadmin :)

This is the same method you would use on CentOS 7 and Red Hat Linux 7.

With this simple example you have learned how to easily change parameters on systemd. In the step where we listed the ipv6 options you will find other options to disable it for just a specific adapter and many more kernel configuration options.

Comments