Skip to content

Instantly share code, notes, and snippets.

@shield-9
Last active August 29, 2015 14:04
Show Gist options
  • Save shield-9/3691b008c034159f8657 to your computer and use it in GitHub Desktop.
Save shield-9/3691b008c034159f8657 to your computer and use it in GitHub Desktop.
https://gist.github.com/shield-9/11131949 のCentOS7(iproute2)対応版
#!/bin/bash
FIRST=$(ip a show dev eth0|grep -E 'inet6 (.+) scope global'|head -n 1|sed -e "s/^ *inet6 *//g"|cut -d ":" -f1,2,3,4)
SECOND=$(ip a show dev eth0|grep -E 'inet6 (.+) scope global'|head -n 1|cut -d ":" -f5,6,7,8|cut -d "/" -f1)
if [ -z "${FIRST}" -o -z "${SECOND}" ]; then
exit 0
fi
case "${SECOND}" in
a[0-9]* ) exit 0
esac
IPV6=${FIRST}:a${SECOND}
for SUFFIX in `echo {0..9}`
do
ip addr add ${IPV6}${SUFFIX}/64 dev eth0
done
for SUFFIX in `echo {a..f}`
do
ip addr add ${IPV6}${SUFFIX}/64 dev eth0
done
exit 0
@shield-9
Copy link
Author

This code is in the Public Domain!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment