Disable IPv6 in Linux

Try using wireshark to analyse your network traffic, you will be surprised to see so much of IPv6 traffic that you are not expecting in your IPv4 based network. IPv6 is enabled by default in all server network interfaces and these packets are actually consuming your server and network resources for no use.

This article explains how to disable IPv6 in the network interface cards of Linux servers.

Step 1: “ip address” command shows that IPv6 is unnecessarily enabled on the interfaces.

server@it:~$ 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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:15:7e:46:8d:63 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.2/24 brd 192.168.1.1 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::215:5dff:fe64:8d36/64 scope link
valid_lft forever preferred_lft forever

 

Step 2:  use editor to add configurations to disable IPv6

server@it:~$ sudo nano /etc/sysctl.conf

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

All in One WordPress Hosting Starts at 30$ per month
All in One WordPress Hosting
WordPress
High optimized WordPress hosting, secure firewall, HTTPS, Backup, hack-fix guarantee and many others at 30$ per month

Step 3: reload sysctl

server@it:~$ sudo sysctl -p

 

Step 4: review interfaces

server@it:~$ 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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:15:7e:46:8d:63 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.2/24 brd 192.168.1.1 scope global eth0
valid_lft forever preferred_lft forever