Disable IPv6 on Ubuntu

0
(0)

How to disable IPv6 addresses on Ubuntu

IPv6 may be undesirable in certain situations, for systems that can run without IPv6 and only operate on IPv4, the IPv6 protocol stack can be disabled.

On Debian and Ubuntu IPv6 stack disable as follows.

sudo vi /etc/sysctl.d/99-sysctl.conf

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

If only one certain interface should run without IPv6, e.g. ens160.

net.ipv6.conf.ens160.disable_ipv6 = 1

Save the sysctl.conf file and enable the setting.

sudo sysctl -p

If you want to deactivate IPv6 during operation, the following command applies.

echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6

Alternatively you can run this command in the terminal shell.

sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1

IPv6 is now disabled, a reboot is not necessary.

If the removal of IPv6 for running services is a disaster, e.g. SSH server, the configuration can be adjusted.

vi /etc/ssh/sshd_config

#AddressFamily any
AddressFamily inet
#or remove hash(#)
#ListenAddress 0.0.0.0
ListenAddress 0.0.0.0

Then restart the SSH daemon.

systemctl restart sshd

Postfix may also require to customize the ipv4 loopback interface.

vi /etc/postfix/main.cf

#inet_interfaces = localhost
inet_interfaces = 127.0.0.1

Checking for IPv6 addresses.

ifconfig | grep inet6

Internet Protocol version 6 (IPv6)

Internet Protocol version 6 (IPv6) is the most recent version of the Internet Protocol (IP), the communications protocol that provides an identification and location system for computers on networks and routes traffic across the Internet. IPv6 was developed by the Internet Engineering Task Force (IETF) to deal with the long-anticipated problem of IPv4 address exhaustion, and was intended to replace IPv4. In December 1998, IPv6 became a Draft Standard for the IETF, which subsequently ratified it as an Internet Standard on 14 July 2017.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Leave a Reply

Your email address will not be published. Required fields are marked *