How to disable IPv6 address on Ubuntu 18.04
We do NOT recommend doing this unless the usage of IPv6 is causing your service a significant impact, in fact in many cases not having IPv6 active as an addon to IPv4 can be an issue.
CrownCloud has IPv6 available across all our locations and provides all our services with IPv6 addresses for free.
In this wiki article, we will learn how to disable IPv6 address on Ubuntu 18.04
Ubuntu 18.04 desktop or server the IPv6 network addresses are enabled by default, Internet Protocol version 6 (IPv6) is the most recent version of the Internet Protocol, the communications protocol that provides an identification and location system for computers on networks and routes traffic across the Internet.
IPv6 is intended to replace IPv4. IPv6 was developed by the Internet Engineering Task Force (IETF) to deal with the long-anticipated problem of IPv4 address exhaustion.
Prerequisite.
- Ubuntu 18.04 Linux Operating system.
- root or sudo Privileged access to your Ubuntu System.
Before we head out to disable the IPv6 address, we'll find out the Network interface of the server by running the following command,
ip a
Output:
root@vps:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 54:52:00:52:3e:cb brd ff:ff:ff:ff:ff:ff
inet 193.29.56.121/24 brd 193.29.56.255 scope global dynamic ens3
valid_lft 21599812sec preferred_lft 21599812sec
inet6 fe80::5652:ff:fe52:3ecb/64 scope link
valid_lft forever preferred_lft forever
To disable IPv6 address
Add the following lines at the end by editing the configuration file /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
To ensure after reboot the IPv6 address to be disabled -- configure the GRUB boot loader.
Find the following lines in the configuration file /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX=""
And change to,
GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1"
GRUB_CMDLINE_LINUX="ipv6.disable=1"
Apply changes by running the following command.
update-grub
To verify perform system reboot and check the network interface to see whether IPv6 address is disabled.
Command to reboot the system.
reboot
Command to check network interface.
ip a
Output:
root@vps:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 54:52:00:52:3e:cb brd ff:ff:ff:ff:ff:ff
inet 193.29.56.121/24 brd 193.29.56.255 scope global dynamic ens3
valid_lft 21599983sec preferred_lft 21599983sec
To disable IPv6 address instantly
Note: These settings will disable IPv6 instantly but after reboot IPv6 address will be again up and running.
sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1
Output:
root@vps:~# sysctl -w net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.all.disable_ipv6 = 1
root@vps:~# sysctl -w net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6 = 1
After executing the above command you can check the network interface to verify the IPv6 address is disabled successfully or not,
ip a
Output:
root@vps:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 54:52:00:52:3e:cb brd ff:ff:ff:ff:ff:ff
inet 193.29.56.121/24 brd 193.29.56.255 scope global dynamic ens3
valid_lft 21599745sec preferred_lft 21599745sec
To enable IPv6 address
To enable IPv6 protocol reverse the above procedure that you have executed.
This would conclude the disable IPv6 address on Ubuntu 18.04
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS