Per default DHCP is configured. However if the raspberry works as server and has to be reached via the network a static address is desired.
Debian 12 Bookworm and Debian 13 Trixie use Networkmanager to configure.
sudo ip a to see what is active
sudo nmtui to get the text user interface of Networkmanager. Edit a connection, select IP4 to manual and enter a manual IP4 address
Address 192.168.1.<n>/24
Gateway 192.168.1.1
DNS 8.8.8.8
disable IP6 and save it and sudo systemctl restart NetworkManager to restart it
sudo ip a to see what happened, if connected with ssh then the address remains an a sudo reboot is required
nmtui is limited, for more settings use nmcli
nmcli connection show
In the following use case the raspberry is connected via eth0 to mobile router having low band width access to the Internet but therefore physically portable and cheap. However when moved to the office for development low bandwidth is an obstacle. Turning on to fast wlan0 would be a booster but the Raspberry would still use eth0 since it has a lower metric value. It would however switch to wlan0 when the eth0 cable gets removed. nmtui can not do this but nmcli can!
To give priority to wlan0 its metric must have a lower value.
nmcli connection show to see the names of the connections
sudo nmcli connection modify "<wlan SSID>" ipv4.route-metric 50 set a low metric and therefore high priority
sudo nmcli connection modify "Wired connection 1" ipv4.route -metric 200 set a high metric and therefore low priority
sudo nmcli connection up "<wlan SSID>" takes the modification
sudo nmcli connection up "Wired connection 1" takes the modification
To see the result: ip route show
default via 192.168.1.1 dev wlan0 proto dhcp src 192.168.1.161 metric 50 default via 192.168.20.1 dev eth0 proto dhcp src 192.168.20.5 metric 200
curl -s https://ifconfig.me will show the wan Internet address of the wlan0 router and uses high the speed connection.
sudo ping -c3 192.168.20.1 will still find the eth0 router
Observe the files in /etc/NetworkManager/system-connections, they contain now the new metric values.
Disable wlan0 and curl -s https://ifconfig.me will show the wan Internet address of the eth0 router and use the low speed mobile connection.
For Debian 11 Bullseye to have a static address edit sudo nano /etc/dhcpcd.conf or sudo mc
Give a static address if the raspberry works as server and will get accessed over the network. It is also possible to turn on networkmanager instead of dhcpcd and then the steps as for Debian 12 can be done.