Getting the Linux IP address without any package (ifconfig, ip address, etc)

1 min read Original article ↗

Explaining how it works

How many times you tried to debug/troubleshoot a Linux with an unprivileged user and you didn’t have net tools or iproute installed? Well, the good news is: You can do it with Bash (ok ok, this not a bash feature :’), without having to install any package.

Many information displayed by those tools are available by the Kernel and most of them doesn’t require a privileged user. Cool, right?

In order to understand how this is possible, we’re going to explore~very shortly~ the IPv4 Routing Subsystem, in specifically the Forwarding Information Base trie (Aka FIB trie). The FIB trie is the main data structure used by the IPv4, it defines the routing trie and can be used by us to collect our IP addresses, gateway IP, netmask, etc.

Routing trie till 192.0.2.48/32 — Credits vincent.bernat.ch