Advertisement
Sergio_Istea

floating_ip.sh

Oct 18th, 2022
1,142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.50 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. primario=192.168.0.25
  4. fallback=192.168.0.34
  5.  
  6. func_setip () {
  7.  
  8.     sed -i "s/$fallback/$primario/" /etc/netplan/01-netcfg.yaml
  9.     netplan apply
  10.     sleep 5
  11.     echo "se cambio la IP:
  12.     $(hostname -I)"
  13. }
  14.  
  15.  
  16. # Vertificar estado en nivel de red
  17. # || operador 'or' ejecuta instruccion si la anterior devuelve
  18. # exit status distinto de 0
  19. # && operador 'and' ejecuta instruccion si la anterior
  20. # devuelve 0
  21.  
  22. while true;do
  23.  
  24. ping -c 1 $primario > /dev/null 2>&1 || func_setip
  25.  
  26. sleep 10
  27.  
  28. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement