Created
July 18, 2026 23:42
-
-
Save saudiqbal/6e1dafcdfd47bd727c54681e5e924b55 to your computer and use it in GitHub Desktop.
Bash command to extract DHCPv6 or SLAAC IPv6 address from a server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### Use any one you like from down below. | |
| ## DHCPv6 | |
| ip -6 addr|awk '{print $2}'|grep -P '^(?!fe80)(?!fd).*/128'|grep '^2'|cut -d '/' -f1 | |
| # | |
| /sbin/ip -6 addr | grep inet6 | grep -vE 'fe80|host|fd|mngtmpaddr|temporary' | grep -F 'scope global dynamic' | sed -e 's/^.*inet6 \([^ ]*\)\/.*$/\1/;t;d' | |
| ## SLAAC | |
| ip -6 addr|grep -E 'inet6 [^!(fe80)!(fd)].*/64.*global dynamic'|awk '{print $2}'|cut -d/ -f1 | |
| # | |
| ip -6 addr|grep -E 'inet6.*/64.*global dynamic'|awk '{print $2}'|grep -P '^(?!fe80)(?!fd)'|cut -d/ -f1 | |
| # | |
| /sbin/ip -6 addr|grep inet6|grep -vE 'temporary'|awk '{print $2}'|grep -P '^(?!fe80)(?!fd).*/64'|cut -d '/' -f1 | |
| # | |
| /sbin/ip -6 addr|grep inet6|grep -vE 'temporary'|grep -F 'scope global dynamic'|awk '{print $2}'|grep -P '^(?!fe80)(?!fd).*/64'|cut -d '/' -f1 | |
| # | |
| ip -6 addr | grep -E 'inet6.*global dynamic' | grep -v 'temporary' | awk '{print $2}' | cut -d/ -f1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment