Displays network interfaces information in a neat table (with awk) using the existing 'ip' command (iproute2).
- Collect IPv4 address information for all network interfaces.
- Display a table with columns for Interfaces, IP Addresses, Subnet Masks, and Broadcasts.
- Ensures columns begin 4 spaces after the longest entry in the previous column (including the headers).
You can use tis as a script or by pasting the entire content into your terminal.
- Save the script to a file (e.g.
network_info.sh). - Make the script executable:
chmod +x network_info.sh
- Navigate to the scripts directory
- Run the script:
./network_info.sh
Interface IP Address Subnet Mask Broadcast
--------- ---------- ----------- ---------
wlp2s0 192.168.1.246 /24 192.168.1.255
br-3dc569643e0f 172.18.0.1 /16 172.18.255.255
docker0 172.17.0.1 /16 172.17.255.255
br-e8b59e2e3d95 192.168.49.1 /24 192.168.49.255
vboxnet0 192.168.56.1 /24 192.168.56.255