Skip to content

Instantly share code, notes, and snippets.

@netmarkjp
Created November 27, 2014 16:13
Show Gist options
  • Save netmarkjp/70bdf1aec0e15a5aeb90 to your computer and use it in GitHub Desktop.
Save netmarkjp/70bdf1aec0e15a5aeb90 to your computer and use it in GitHub Desktop.
ip.sh with nmcli (Network Manager)
#!/bin/bash
IPADDR=${1:?}
GATEWAY=172.16.0.1
DEVNAME="enp0s3"
UUID=$(nmcli -f UUID,DEVICE con show | grep ${DEVNAME:?} | awk '{print $1}')
nmcli con mod ${UUID:?} ipv4.method manual ipv4.addresses "${IPADDR:?}/24 ${GATEWAY}" ipv4.routes "${IPADDR} ${GATEWAY}" ipv4.dns "8.8.8.8 8.8.4.4"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment