6 simple methods to check if ipv6 is enabled in Linux

In this tutorial I will share different methods to check of IPv6 is enabled or disabled in Linux.

 

Check if IPv6 is enabled or disabled

On most Linux distributions by default IPv6 will be in enabled state. Although it is possible that someone may have disabled IPv6 on the server so you must be familiar with the methods and commands to check the state of IPv6 on the Linux server. The commands output which we will discuss in later sections will vary based on environment. Assuming if you have disabled IPv6 using kernel boot entries or GRUB2 then it is possible you will get empty output of most commands. This would mean that IPv6 module itself is unloaded in the kernel hence it is in disabled state.

 

Method 1: Check IPv6 module status

You can check the content of /sys/module/ipv6/parameters/disable file to get the IPv6 status on the Linux server.

If IPv6 is in enabled state, the output would be "0"

# cat /sys/module/ipv6/parameters/disable
0

If IPv6 is in disabled state, the output would be "1"

# cat /sys/module/ipv6/parameters/disable
1

 

Method 2: Using sysctl

In this method we will check the status of IPv6 using sysctl.

If IPv6 is disabled via sysctl and is still in disabled state the output would contain "1" for specific entries:

# sysctl -a 2>/dev/null | grep disable_ipv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.eth0.disable_ipv6 = 0
net.ipv6.conf.eth1.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0

 

If IPv6 is disabled via GRUB2 or kernel boot entries then the output would be empty which would again mean that IPv6 is in disabled state:

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

 

If IPv6 is in enabled state, all the parameters in the output would have "0" as the value

check if IPv6 is enabled or disabled in Linux
sysctl output to check IPv6 status

 

Method 3: Check if IPv6 address is assigned to any interface

By default a IPv6 address will be assigned to every available interface in Linux. Even if you do not have an IPv6 configuration, each interface will get a global address, eg: 2001::1/64 or a link-local address fe80::x/64.

If IPv6 is in enabled state you will get some output on the console where interface will have either global or link local address based on your environment:

check if IPv6 is in enabled state
check if IPv6 is enabled with ip command

If IPv6 is in disabled state then you will get an empty output

# ip -6 addr
IMPORTANT NOTE:

Method 1-3 are the most reliable methods to check if IPv6 is enabled or disabled. In the remaining section I will share the commands to check the IPv6 socket address. It is possible if someone has disabled IPv6 using sysctl and still system services and process would continue to bind to inet6 socket as the IPv6 module is still getting loaded.

 

Method 4: Check for any IPv6 socket using netstat

You can look out for any service which is using IPv6 socket on tcp6 or udp6, one of the method to check this is using netstat command.

If IPv6 is in enabled state, you will most likely find some active sockets:

netstat command to check IPv6 status
ipv6 socket status using netstat

 

If IPv6 is in disabled state, the most likely you will get an empty output

# netstat -tunlp | grep -iE 'udp6|tcp6'

Here,

-t represents all TCP connections
-u represents all UDP connections
-n means show numerical addresses instead of trying to determine symbolic host, port or user names
-l is to show only listening sockets
-p is to show the PID and name of the program to which each socket belongs

 

Method 5: Check for listening IPv6 socket using ss

ss is another utility to investigate sockets. It is an alternative to netstat command and it can display more TCP and state information than other tools.

If IPv6 is in enabled state then you will get a list of services and process which are bound to IPv6 socket

check if IPv6 is enabled or disabled with ss command
ss command output to check IPv6 status

If IPv6 is in disabled state then the output would most likely be empty:

# ss -6 -pan
Netid     State      Recv-Q       Send-Q              Local Address:Port             Peer Address:Port

As you see we have no service or process listening on IPv6 socket so IPv6 is expected to be in disabled state

Here,

-p is used to show process using socket
-a is to display both listening and non-listening (for TCP this means established connections) sockets.
-n means do not try to resolve service names
-6 is to display only IP version 6 sockets (alias for -f inet6)

 

Method 6: Check for listening addresses using lsof

lsof is used to check the list of open files but it can also help us determine if any files are using IPv4 or IPv6 address.

If IPv6 is in enabled state then you should get some output with the list of files using IPv6 address

check if Ipv6 is enabled or disabled with lsof
lsof command output with files using Ipv6 address

If IPv6 is in disabled state, then the output of the same command would be empty:

# lsof -a -i6

 

What's Next

Now since you know the status of IPv6 on your Linux server, you can plan to configure your network:

 

Conclusion

In this tutorial I showed you different methods you can choose to check if IPv6 is enabled of disabled on the Linux server. You can easily integrate the commands from this tutorial in any script to automate the process.

Lastly I hope the steps from the article to check for IPv6 status on Linux was helpful. So, let me know your suggestions and feedback using the comment section.

 

Leave a Comment

Please use shortcodes <pre class=comments>your code</pre> for syntax highlighting when adding code.