Raspbian
Raspbian is a lightweight, Debian-based Linux distribution optimized specifically for the Raspberry Pi single-board computers, offering a tailored user experience and support for the hardware features of these devices.
Categories:
2 minute read
Determine OS
$ hostnamectl
Static hostname: pi-server
Icon name: computer
Machine ID: a3e83f5bda884aa685532bf63809cb3f
Boot ID: ce0dfa377b234aa38af1243a20591d0a
Operating System: Debian GNU/Linux 12 (bookworm)
Kernel: Linux 6.1.0-rpi7-rpi-v8
Architecture: arm64
Set a static IP on Bookworm
With the release of Raspberry Pi OS Bookworm, networking on the Raspberry Pi was changed to use NetworkManager as the standard controller for networking, replacing the previous dhcpcd system. NetworkManager includes a command line tool called “nmcli,” which can control NetworkManager and report on the network status.
- Get name of the device
$ sudo nmcli -p connection show
======================================
NetworkManager connection profiles
======================================
NAME UUID TYPE DEVICE
------------------------------------------------------------------------------------------------------------------
Wired connection 1 77fec910-9ee6-31d0-8aeb-fd3f833bff71 ethernet eth0
lo a4d7024d-0288-4ff5-bda7-0005526414cd loopback lo
- Three commands to set the new IP address, Gateway and DNS server.
sudo nmcli c mod "Wired connection 1" ipv4.addresses 10.0.0.3/24 ipv4.method manual
sudo nmcli con mod "Wired connection 1" ipv4.gateway 10.0.0.1
sudo nmcli con mod "Wired connection 1" ipv4.dns "10.0.0.1"
- Restart the network connection with the following command.
sudo nmcli c down "Wired connection 1" && sudo nmcli c up "Wired connection 1"
Set a static IP on Bullseye
You need some data first. So get the following
# Name of your network card
ifconfig
# Get the DNS server IP
cat /etc/resolve.conf
# The Gateway IP
route -n
Now edit your DHCPD configuration file
sudo nano -w /etc/dhcpcd.conf
Scroll down to the Example static IP configuration
section and uncomment out the lines
# Example static IP configuration:
interface eth0
static ip_address=192.168.0.10/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
static routers=192.168.0.254
#static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1
Reboot the Pi and connect on the static IP
sudo reboot
Last modified July 21, 2024: update (e2ae86c)