How to Check If IPv6 is Enabled in Linux

How to Check If IPv6 is Enabled in Linux

Most Linux distributions come with IPv6 support and it is usually enabled by default. But if you need to work with Ipv6, it is best to check the state of Ipv6 on your Linux server. In this tutorial, we will show you 3 methods to check if IPv6 is enabled in your system and how to find the IPv6 address for your server.

Method 1: How to Check If IPv6 is Enabled Via Command Line

The easiest way to verify IPv6 is by checking IPv6 status with a simple command:

	
		ip a | grep inet6 
	

If IPv6 is in enabled state, you will see an output similar to the following:

	
		inet6 ::1/128 scope host 
	

If you do not see any output after you run this command, then IPv6 is not enabled.

Method 2: Check IPv6 Status Via IPv6 Module

Another easy way to check for IPv6 state is to check the state of IPv6 module located in /sys/module/ipv6/parameters/disable, and you can use the cat command to check its content.

	
		cat /sys/module/ipv6/parameters/disable
	

Copy and paste the above command into your terminal and check the output:

  • 0: IPv6 is enabled
  • 1: IPv6 is not enabled

Method 3: Check IPv6 With sysctl

This is our last method by using sysctl.

	
		sysctl -a 2>/dev/null | grep disable_ipv6
	

After you run the above command, you should see something similar to the below output:

	
		net.ipv6.conf.all.disable_ipv6 = 0
		net.ipv6.conf.default.disable_ipv6 = 0
		net.ipv6.conf.eth0.disable_ipv6 = 0
		net.ipv6.conf.lo.disable_ipv6 = 0
	

The rule is the same as the IPv6 module, if you see 0, then it is enabled, else it is not.

What is My IPv6 Address

You can use the following commands to check all the IPv6 addresses you have for the interface on Linux.

This command will return all the configured IPv6 addresses along with other useful information:

	
		ip -6 addr
	

If the above command is returning too much information, you can run the following command to return only the address:

	
		ip addr show dev eth0 | sed -e's/^.*inet6 \([^ ]*\)\/.*$/\1/;t;d'
	

Tutorial Summary

We learned how to check if IPv6 is enabled via the following 3 commands:

  • ip a | grep inet6
  • cat /sys/module/ipv6/parameters/disable
  • sysctl -a 2>/dev/null | grep disable_ipv6

We also learned how to get the IPv6 addresses with the following 2 commands:

  • ip -6 addr
  • ip addr show dev eth0 | sed -e’s/^.*inet6 \([^ ]*\)\/.*$/\1/;t;d’

You May Also Like