Advertisement
eudemonics

Flush WiFi route tables and restart WiFI interfaces - OSX

Nov 10th, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.63 KB | None | 0 0
  1. #!/bin/bash
  2. # chmod +x flushwifi.sh
  3. # run as root or sudo: ./flushwifi.sh
  4. # AUTHOR: vvn <vvn [at] notworth.it>
  5. # DESCRIPTION: bash script that briefly disables WiFi interfaces and clears the routing tables.
  6.  
  7.  
  8. if (( $(id -u) )) ; then
  9.     echo "this script needs to run as root or sudo"
  10.     exit 1
  11. fi
  12.  
  13. echo "refreshing wifi services.."
  14.  
  15. WIFINT=`ifconfig -l | grep -oh en[1-9]`
  16.  
  17. for i in $WIFINT
  18.   do
  19.     ifconfig $i down
  20.     echo "interface $i temporarily disabled"
  21.     sleep 2
  22.     route -n flush
  23.     echo "routes flushed"
  24.     sleep 2
  25.     ifconfig $i up
  26.     sleep 1
  27.   done
  28.  
  29. echo "Wi-Fi successfully restarted."
  30.  
  31. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement