![Get Linux IP address without any packages (ifconfig, IP address, etc.) - Linux Tips and Tricks](https://ytimg.googleusercontent.com/vi/lmogUjLsAdY/oar2.jpg)
How many times have you used an unprivileged user to attempt to debug or troubleshoot a Linux network without having Net Tools or IProute installed? The good news is that you can achieve this without installing a package using Bash (well, yes, it's not a bash feature).
To get started, here are the two most common methods (don't get me wrong, there are other methods) for obtaining your network's IP address.
grep inet IP address
ifconfig grep inet
As mentioned before, you do not have these packages installed and you are not a super user, you will not be able to use these commands.
Well, there is hope, and this YouTube video will share that hope.
METHOD 1 – hostname
Use the hostname command with the -I flag to obtain your network IP address. It couldn't be simpler.
hostname -I
METHID 2 – IP address of the fib_trie file.
View the contents of the fib_trie file using the cat command. It's a bit of a mess.
cat /proc/net/fib_trie
This is how you get the primary IP address.
awk '/32 host/ { print i } {i2}' /proc/net/fib_trie
And this is how you get a primary and secondary IP address.
awk '///–/ && !///.0//.255/ {print 2}' /proc/net/fib_trie
#linux #ubuntu #redhat #bash
Please take the opportunity to connect and share this video with your friends and family if you find it useful.
No Comments