Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- gw_arr=( "192.168.0.1" "192.168.0.254" "192.168.0.2" "192.168.0.3" )
- rm /tmp/list.txt
- for gw in ${gw_arr[@]}; do
- echo $(ping -c 1 $gw| awk -F'time=' '/time=/{print $2}' | cut -d " " -f 1) $gw >> /tmp/list.txt
- done
- gateway=$(sort /tmp/list.txt | head -1 | cut -d " " -f 2)
- echo $gateway
- # setear el gateay en el sistemao
- #
- echo "Gateway $gateway online, seteando"
- echo "ip route add default via $gateway"
Advertisement