Skip to content

Instantly share code, notes, and snippets.

@themactep
Forked from LozanoMatheus/get_ip.sh
Created September 4, 2022 03:17
Show Gist options
  • Save themactep/321de7836ae85f23131fc4b96d0765ff to your computer and use it in GitHub Desktop.
Save themactep/321de7836ae85f23131fc4b96d0765ff 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