- How do I get the pingable IPv6 address of my machine?
- 2 Answers 2
- 6 simple methods to check if ipv6 is enabled in Linux
- Check if IPv6 is enabled or disabled
- Method 1: Check IPv6 module status
- Method 2: Using sysctl
- Method 3: Check if IPv6 address is assigned to any interface
- Method 4: Check for any IPv6 socket using netstat
- Method 5: Check for listening IPv6 socket using ss
- Method 6: Check for listening addresses using lsof
- What’s Next
- Conclusion
- IPv6 on Linux | The Definitive Guide
- How to disable IPv6 on Linux
- How to enable IPv6 on Linux
- Troubleshooting IPv6 on Linux
How do I get the pingable IPv6 address of my machine?
when I try: $ ip -6 addr I get something like: inet6 fe80::d773:9cf0:b0fd:572d/64 scope link if I try to ping that from the machine itself:
$ ping6 fe80::d773:9cf0:b0fd:572d/64 unknown host $ ping6 fe80::d773:9cf0:b0fd:572d connect: Invalid argument
2 Answers 2
Any IPv6 address that starts with fe80: is the equivalent of IPv4 169.254.*.* address, i.e. it’s a link-local address, reachable only in the network segment it’s directly connected to, using the NIC that connects to that segment specifically. Unlike IPv4, however, it is perfectly normal for a NIC to have both the link-local IPv6 address and one or more global IPv6 addresses simultaneously.
Since a fe80: IPv6 address is link-local, you must specify the network interface you want to use when pinging it.
$ ping6 fe80::beae:c5ff:febe:a742 connect: Invalid argument $ ping6 -I eth0 fe80::beae:c5ff:febe:a742 PING fe80::beae:c5ff:febe:a742(fe80::beae:c5ff:febe:a742) from fe80::beae:c5ff:febe:a742%eth0 eth0: 56 data bytes 64 bytes from fe80::beae:c5ff:febe:a742%eth0: icmp_seq=1 ttl=64 time=0.182 ms 64 bytes from fe80::beae:c5ff:febe:a742%eth0: icmp_seq=2 ttl=64 time=0.167 ms .
You can also append the interface at the end of the address by using the % sign: ping6 fe80::beae:c5ff:febe:a742%eth0 .
This requirement is only for link-local IPv6 addresses: you can ping globally routable IPv6 addresses without specifying the interface.
$ ping6 2a00:1450:400f:80a::200e # that's ipv6.google.com PING 2a00:1450:400f:80a::200e(2a00:1450:400f:80a::200e) 56 data bytes 64 bytes from 2a00:1450:400f:80a::200e: icmp_seq=1 ttl=55 time=17.6 ms 64 bytes from 2a00:1450:400f:80a::200e: icmp_seq=2 ttl=55 time=19.6 ms .
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
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:
If IPv6 is in disabled state then you will get an empty output
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:
If IPv6 is in disabled state, the most likely you will get an empty output
# netstat -tunlp | grep -iE 'udp6|tcp6'
-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
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
-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
If IPv6 is in disabled state, then the output of the same command would be empty:
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.
Didn’t find what you were looking for? Perform a quick search across GoLinuxCloud
If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.
For any other feedbacks or questions you can either use the comments section or contact me form.
Thank You for your support!!
IPv6 on Linux | The Definitive Guide
Let’s have a look at IPv6 support and some history for Microsoft Windows, Apple MacOS and Linux implementations of our new Internet Protocol.
In 1996 – after the first Draft of the IPv6 Specification from December 1995 in RFC1883 the first IPv6 code was included in Linux Kernel 2.1.8.
In 2000 – the Japanese USAGI project sets a goal to fully implement IPv6 on Linux.
In 2008 – the IPv6 implementation in Linux was nearly complete in Kernel 2.6.
Please watch my following video with an introduction to IPv6 for the different operating systems, including Linux:
You know what traceroute is and why it is so helpful. The Linux utility My Traceroute (mtr), which is also available for MacOS via homebrew, does a kind of a live traceroute and sends packets every second. You are able to see live where packet loss happens or latency increases. I love this tool and highly recommend you try it out, for IPv6 and IPv4!
How to disable IPv6 on Linux
I cannot recommend disabling IPv6 on Linux and recommend learning enough about it so you can configure and enjoy it. Disabling IPv6 might also break some things that are dependent on it. Still, in some cases you might want or even need to disable it.
First, disable IPv6 in runtime on your Linux machine:
$ sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1 $ sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1 $ sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
And depending on your Linux distribution you might need to make sure this is reboot safe by writing it into /etc/sysctl.conf:
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.all.disable_ipv6 = 1
Now you can reboot your Linux machine into an IPv6 free state.
If you had enough of life without IPv6, read on:
How to enable IPv6 on Linux
I’m glad you want to (re-) enable IPv6 on your Linux machine. This should be quick and easy.
First, enable IPv6 in runtime on your Linux machine:
$ sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0
$ sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=0
$ sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
And depending on your Linux distribution you might need to make sure this is reboot safe by writing it into /etc/sysctl.conf:
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0
net.ipv6.conf.all.disable_ipv6 = 0
Now you can reboot your Linux machine to be back on full IPv6 support. In case you need to do more configuration, follow the previous steps on how to configure addresses and routing and how you troubleshoot your Linux IPv6 implementation.
Troubleshooting IPv6 on Linux
Watch my video on troubleshooting IPv6 on Linux:
This concludes IPv6 Foundation Part 8: IPv6 on Linux of the original IPv6 Foundation Master Class.