Skip to content

Instantly share code, notes, and snippets.

@pepoviola
Forked from LozanoMatheus/get_ip.sh
Created August 24, 2023 13:24
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 pepoviola/7add9bac80c3c5dd53396f36dadc52be to your computer and use it in GitHub Desktop.
Save pepoviola/7add9bac80c3c5dd53396f36dadc52be 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