Skip to content

Instantly share code, notes, and snippets.

@satouriko
Created February 12, 2018 10:51
Show Gist options
  • Save satouriko/fa6f5a998a7838b5ce03991b3e2a084a to your computer and use it in GitHub Desktop.
Save satouriko/fa6f5a998a7838b5ce03991b3e2a084a to your computer and use it in GitHub Desktop.
#!/bin/bash
#########################################################################
# File Name: fix-conoha-v6-route.sh
# Author: LI JIAHAO
# ###############
# Mail: [email protected]
# Created Time: Mon 12 Feb 2018 04:59:12 PM CST
#########################################################################
#route_cmd='cat ip6route'
route_cmd='ip -6 route'
declare -i try_times=10
while (( $try_times > 0 )); do
has_fd00=`$route_cmd`
if [[ "$has_fd00" =~ 'fd00::' ]]; then
try_times=0
else
sleep 5
try_times=$try_times-1
fi
echo $has_fd00
echo $try_times
done
has_default=`$route_cmd | sed -n "s/\(default\) via .* dev eth0 proto ra.*/\1/p"`
if [ "$has_default" != 'default' ]; then
ipsuffix=`$route_cmd | sed -n "s/.*2.*:\([0-9]\+\):\+\/[0-9]\+ dev eth0 proto kernel.*/\1/p"`
ip="fe80::$ipsuffix:1"
cmd="$route_cmd add default via $ip dev eth0 proto ra"
$cmd
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment