How to detect if system has IPv6 enabled in a UNIX shell script? How to detect if system has IPv6 enabled in a UNIX shell script? shell shell

How to detect if system has IPv6 enabled in a UNIX shell script?


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.