netface
netface
is a simple Bash command‑line utility that provides a quick, at‑a‑glance summary of your network interfaces and external IP information. It displays each interface’s state, MAC address, IPv4/IPv6 addresses, default gateway, and DNS servers, plus your current public IP and the system’s primary DNS resolver.
Features
- Lists all non-loopback network interfaces
- Shows interface STATE, MAC, IPv4, IPv6, GATEWAY, and DNS
- Fetches and displays your External IP
- Footers the external IP with the system’s primary DNS resolver
- Falls back gracefully if certain tools or data are unavailable
Requirements
- bash (v4+)
- iproute2 (
ip
command) - One of:
- curl (to fetch external IP from ifconfig.me)
- dig (to fetch external IP via OpenDNS)
- resolvectl (optional, for per‑interface DNS; falls back to
/etc/resolv.conf
)
Installation
- Save the script as
netface
in a directory on yourPATH
, e.g.~/bin/netface
: - Make it executable:
chmod +x ~/bin/netface
- Ensure
~/bin
(or wherever you saved it) is in yourPATH
:export PATH="$HOME/bin:$PATH"
Usage
netface
Sample Output
INTERFACE STATE MAC IPv4 IPv6 GATEWAY DNS
---------- -------- ----------------- -------------------- -------------------- --------------- --------------------
eth0 up 1a:2b:3c:4d:5e:6f 192.168.1.23/24 fe80::1234/64 192.168.1.1 192.168.1.1
wlan0 down 0a:1b:2c:3d:4e:5f – – – –
enp3s0 up aa:bb:cc:dd:ee:ff 10.0.0.15/16 2001:db8::abcd/64 10.0.0.1 10.0.0.2
docker0 up 02:42:ac:11:00:02 172.17.0.1/16 – – –
tun0 up 00:00:00:00:00:00 10.8.0.2/24 – 10.8.0.1 10.8.0.1
External IP: 203.0.113.47 (DNS: 8.8.8.8)
Column Breakdown
- INTERFACE: Name of the network interface (e.g.
eth0
,wlan0
). - STATE: Operational state (
up
,down
, etc.). - MAC: Hardware (MAC) address.
- IPv4: Assigned IPv4 CIDRs.
- IPv6: Assigned global-scope IPv6 CIDRs.
- GATEWAY: Default IPv4 gateway for the interface.
- DNS: Primary DNS server(s) for the interface (or system fallback).
In the footer:
- External IP: Your public IP as seen by external services.
- DNS: The system’s primary DNS resolver, used for external lookups.
Customization
This was sort of tailored to my needs, but if you need more data, here's a quick-start-quide:
- To adjust column widths, edit the
printf
format strings at the top of the script. - To include RX/TX counters, link speeds, or other metrics, add additional
ip
,ethtool
, or/sys/class/net
queries in the loop.
Troubleshooting
- If MAC or gateway fields appear empty, confirm you have permissions to read
/sys/class/net
and thatiproute2
is installed. - If External IP fails, install
curl
ordnsutils
(fordig
). - If DNS is incorrect, ensure
resolvectl
is available or/etc/resolv.conf
is properly populated.
Description
A simple Bash command‑line utility that provides a quick, at‑a‑glance summary of your network interfaces and external IP information. It displays each interface’s state, MAC address, IPv4/IPv6 addresses, default gateway, and DNS servers, plus your current public IP and the system’s primary DNS resolver.
Languages
Shell
100%