Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  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}"
  5.  
  6. IFS='.' read -r -a ip_array <<< "$ip"
  7. ip_array[-1]=136
  8. newip=`echo ${newip} | sed 's/,/./g'`
  9.  
  10. sudo dhclient -r $network
  11. sudo ip link set dev $network down
  12.  
  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
  15.  
  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 script...so it should only refresh the static ip)"
  18. sudo dhclient $network
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement