I have a shell script, that is being executed on various POSIX environments such as Linux, Mac OSX or even Cygwin. The script needs to reliably detect if given system has IPv6 enabled. E.g. I can use at least IPv6 local loopback (::1). So the question is: How to detect if system has ipv6 enabled in a UNIX shell in a POSIX compatible way?
This can be tested by checking the existance of /proc/net/if_inet6
as follows:
test -f /proc/net/if_inet6 && echo "IPv6 supported" || echo "IPv6 not supported"
I've tested it on Ubuntu, Mint, Raspberry PI and Bash shell in Windows, and it works in all these environments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With