0

What networking system is my Pi using?
Recent changes with Bookworm mean many of the older methods don't work.

Milliways
  • 62,573
  • 32
  • 113
  • 225

1 Answers1

1

I have a number of Pi (mostly headless) running a range of Operating Systems and different network managers.

I had a number of code fragments to check networking but a different set is needed for each so I decided to write a single script that would run on most systems and show significant network settings.

Download latest from https://github.com/Milliways2/Raspberry-Pi-Utilities/blob/main/netstats

#! /bin/sh
# This script prints useful diagnostics for common Pi networking systems

Function to print coloured headings

delete "tput" lines for plain output

print_head () { tput setaf 6 echo $1 tput sgr 0 }

checkactive () { if [ $(systemctl is-active $1) = 'active' ]; then echo $1 'active' fi }

print_head "- Networking System"

Check status of networking system

checkactive 'systemd-networkd' checkactive 'dhcpcd' checkactive 'NetworkManager' checkactive 'networking'

print_head "- IP addresses & routes"

Print IP addresses & routes

ip a echo ip r

print_head "- Network Devices" ls /sys/class/net # network devices

print_head "- Connected WiFi"

Get SSID of connected WiFi (WRONG if AP!)

if [ -e /sys/class/net/wlan0 ]; then if [ $(systemctl is-active 'NetworkManager') = 'active' ]; then nmcli connection show | awk '/wlan0/ {print $1}' else wpa_cli -i wlan0 status | grep -w ssid | awk -F'[=]' '{print $2}' fi fi

print_head "- Available WiFi connections" if [ -e /sys/class/net/wlan0 ]; then if [ $(systemctl is-active 'NetworkManager') = 'active' ]; then nmcli connection show | awk '/wifi/ {print $1}' else wpa_cli list_networks | awk '/any/ {print $2}' fi fi

The output on Raspberry Pi OS Bookworm 64bit is:-

- Networking System
NetworkManager active
networking active
- IP addresses & routes
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host noprefixroute 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether dc:a6:32:02:23:24 brd ff:ff:ff:ff:ff:ff
    inet 10.1.2.74/24 brd 10.1.2.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::d388:e56f:5ecf:406d/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether dc:a6:32:02:23:25 brd ff:ff:ff:ff:ff:ff
    inet 10.42.0.1/24 brd 10.42.0.255 scope global noprefixroute wlan0
       valid_lft forever preferred_lft forever
    inet6 fe80::dea6:32ff:fe02:2325/64 scope link 
       valid_lft forever preferred_lft forever

default via 10.1.2.1 dev eth0 proto dhcp src 10.1.2.74 metric 100 10.1.2.0/24 dev eth0 proto kernel scope link src 10.1.2.74 metric 100 10.42.0.0/24 dev wlan0 proto kernel scope link src 10.42.0.1 metric 600

  • Network Devices

eth0 lo wlan0

  • Connected WiFi

Hotspot

  • Available WiFi connections

Hotspot WiFi-B13A WiFi-B13A-5G

Milliways
  • 62,573
  • 32
  • 113
  • 225