Skip to content

Instantly share code, notes, and snippets.

@jhyland87
Last active June 7, 2016 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhyland87/66ae0d7ce375c5e77743e69cf900f43a to your computer and use it in GitHub Desktop.
Save jhyland87/66ae0d7ce375c5e77743e69cf900f43a to your computer and use it in GitHub Desktop.
Getting the local IP, and mod the 2nd octet
#!/bin/bash
# From: http://unix.stackexchange.com/a/287364/157820
nmcli con show eno16777984 | awk -F"/|[[:space:]]+" '
/^ipv4.address/ {
if ($2 ~ /^10\.10/) {
sub(/10\.10/,"10.20",$2);
} else if ($2 ~ /^10\.20/) {
sub(/10\.20/,"10.10",$2);
};
print $2;
};'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment