Skip to content

Instantly share code, notes, and snippets.

@user890104
Created December 10, 2018 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save user890104/80aef7c6cb4582f54eb04486bd63a80d to your computer and use it in GitHub Desktop.
Save user890104/80aef7c6cb4582f54eb04486bd63a80d to your computer and use it in GitHub Desktop.
Fix network on lxd
for cnt in $(lxc list --format csv --columns n)
do
GATEWAY_NUM=$(lxc exec $cnt -- bash -c 'route -n -A inet6 | grep -F "::/0" | grep -Fv "!n" | wc -l')
if [ $GATEWAY_NUM -eq 0 ]
then
echo restart network on $cnt
lxc exec $cnt -- netplan apply
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment