a guest Jun 17th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # network=wlan0
  2. network=eth0
  3. ip=`ip -4 addr show ${network} | grep inet | awk '{print $2}' | cut -d/ -f1`
  4. echo "Current ip is: ${ip}"
  6. IFS='.' read -r -a ip_array <<< "$ip"
  7. ip_array[-1]=136
  8. newip=`echo ${newip} | sed 's/,/./g'`
  10. sudo dhclient -r $network
  11. sudo ip link set dev $network down
  13. echo "Does the below set the network ip??? When I bring the network up, it seems to revert back to its dhcp-assigned ip. :("
  14. sudo ip address add $newip dev $network
  16. sudo ip link set dev $network up
  17. echo "Does anyone know why or if I have to bring the dhclient back up? I really don't want DHCP messing with things unless there is a restart (which this script will be a startup it should only refresh the static ip)"
  18. sudo dhclient $network
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand