or, I can’t remember what the commands are. I promise to write them down this time...
This writeup is for people on modern Linux desktops or servers that just happen to find themselves in the terminal when they decide networking information is needed and are unfamiliar with
ifconfig or would rather use its successor,
ip -br -c a
This command is likely the one you’re looking for. It and the later
ip commands break down like this.
ip queries the IP stack,
-br (brief) requests the information be formatted and slimmed down as much as possible,
-c (color) adds a splash of color, and finally the
a at the end (notice there’s no
-) is short for “address.”
ip -br -c l
This command, like the previous command asks
ip to be brief, and colorize, but instead of querying the addresses, it asks for the data link information with
l. In other words, what’s my MAC address?
ip -br -c n
A little into the weeds, but this command can be really useful if you need to know the IP or MAC addresses of the devices your computer has been in contact with. The router will, no doubt, be on the list, but so will others in many cases. STALE in the output here just means my machine hasn’t communicated with this entry in a while, while FAILED is where things end up after prolonged non-contact.
ip -c r
This command answers the age old question of “What’s my default gateway?” This is also called “router” or “default route” in some cases. Regardless, it will show the IP address that your router uses to forward your traffic out to the internet. You get this with the
r at the end. Keep your eye on that first line. It starts with
default via. That’s your default gateway.
Sometimes you need to know what your current DNS provider is before making any changes. The command above will show you these DNS servers on each interface.
Gross. Have you seen the output?
Sure, it’s faster to type. That’s about all it’s got going for it. Let’s add color and formatting. You can do it the hard way if you want. The command’s right there, but I’m not responsible for the multiple wasted seconds trying to parse all that.
ifconfig is Dead
Most distributions have moved to the
iproute2 package for networking tools, and
ifconfig is slowly fading away.