How to disable IPv6 address on Ubuntu 18.04 Bionic Beaver Linux

op

Objective

The objective is to disable IPv6 on Ubuntu Bionic Beaver Linux

Operating System and Software Versions

  • Operating System: - Ubuntu 18.04 Bionic Beaver Linux

Requirements

Privileged access to your Ubuntu System as root or via sudo command is required.

Conventions

  • # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
  • $ - given linux commands to be executed as a regular non-privileged user

Other Versions of this Tutorial

Ubuntu 20.04 (Focal Fossa)

Instructions

Whether you are running Ubuntu 18.04 desktop or server the IPv6 network addresses are enabled by default. In most of the cases this default setting can be simply ignored. 

However, in case that you need to disable the IP version 6 network protocol on your Ubuntu 18.04 Desktop or Server this tutorial we help you to do just that.

Disable IPv6 Network Address

Ip version 6 enabled on Ubuntu 18.04 by default
IPv6 network protocol is enabled on Ubuntu 18.04 Linux by default. Execute ip a linux command from your command line to see your current network settings.

SUBSCRIBE TO NEWSLETTER
Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


The simplest way to instantly disable the IP version 6 network protocol system on on Ubuntu 18.04 is to execute the following commands:
$ sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
$ sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
IP version 6 disabled on Ubuntu 18.04
After executing the above sysctl command the IPv6 network addresses are no longer present.
The above IPv6 disable settings would not persist after the reboot. The usual way on how to load the above settings is to edit the /etc/sysctl.confconfiguration file by adding the following lines:
net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
WARNING: Please note, that at the time of writing this method to disable IPv6 after reboot using /etc/sysctl.conf configuration file on Ubuntu 18.04 does Not work. However, this seems to be a bug so feel free to try.
The recommend method to disable IPv6 on Ubuntu 18.04 after reboot is to configure the GRUB boot loader to pass kernel parameter during the boot time. 

To do so open the /etc/default/grub using your favorite text editor with root privileges and change/add:
FROM:
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX=""
TO:
GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1"
GRUB_CMDLINE_LINUX="ipv6.disable=1"


Disable IPv6 protocol after reboot on Ubuntu 18.04 using GRUB
Disable IPv6 protocol after reboot on Ubuntu 18.04 using GRUB.
Once you have made the above change within the /etc/default/grub file execute the following commands to apply the GRUB changes:
$ sudo update-grub
All done. Optionally reboot your Ubuntu 18.04 system.

Enable IPv6 Network Address

To enable IPv6 protocol simply reverse the above procedure. To immediately disable IPv6 protocol execute:
$ sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
$ sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0
In case you have also configured the /etc/sysctl.conf configuration file remove the appropriate lines. Lastly, edit the /etc/default/grub using your favorite text editor with root privileges and change/remove:
FROM:
GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1"
GRUB_CMDLINE_LINUX="ipv6.disable=1"
TO:
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX=""
When ready execute:
$ sudo update-grub
to apply changes made to the GRUB boot loader configuration.

 

How to disable IPv6 address on Ubuntu 18.04 Bionic Beaver Linux

NetworkConfiguration

posted @ 2019-04-26 07:20  PKICA  阅读(220)  评论(0编辑  收藏  举报