Skip to content

Instantly share code, notes, and snippets.

@LozanoMatheus
Created November 30, 2020 21:41
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save LozanoMatheus/09c8537cba9586e0ba8a8f7e18c9ce17 to your computer and use it in GitHub Desktop.
Save LozanoMatheus/09c8537cba9586e0ba8a8f7e18c9ce17 to your computer and use it in GitHub Desktop.
Get Linux IP without any tool
#!/usr/bin/env bash
## Get the primary and secundary IPs
awk '/\|--/ && !/\.0$|\.255$/ {print $2}' /proc/net/fib_trie
## Get only the primary IPs
awk '/32 host/ { print i } {i=$2}' /proc/net/fib_trie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment