Skip to content

Instantly share code, notes, and snippets.

@alanbchristie
Last active December 15, 2023 07:26
Show Gist options
  • Save alanbchristie/6ea94386ccee8e4b8263c1d85f266cb3 to your computer and use it in GitHub Desktop.
Save alanbchristie/6ea94386ccee8e4b8263c1d85f266cb3 to your computer and use it in GitHub Desktop.
Raspberry Pi OS - setting a fixed IP4 address
# Fixed IP4 address are handy.
# To avoid DHCP you can set a fixed address
# by editing '/etc/dhcpcd.conf'.
#####
# 0 #
#####
# For newer RPi operatign systems (like Debian Bookworm)
# you might need to use this method: -
#
# Show the list of interfaces with
sudo nmcli c show
# Then modify the wired interface, for example, like this before rebooting: -
sudo nmcli c mod "Wired connection 1" ipv4.addresses 192.168.0.8/24
#####
# 1 #
#####
# If you're not using nmcli these instrctions apply: -
#
# Get the appropriate interface,
# i.e. the fixed 'eth0' or maybe the
# wireless 'wlan0' (or both)
$ ifconfig
[...]
#####
# 2 #
#####
# Edit '/etc/dhcpcd.conf'
# and add something like this where the example static IP configuration is illustrated...
# Here we're setting the local IP to '192.168.0.10'
# with a DNS server on the network at '192.168.0.1'...
$ sudo vi /etc/dhcpcd.conf
[...]
interface eth0
static ip_address=192.168.0.10/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1 8.8.8.8
# You'll probably use wlan0 for a wireless adapter.
#####
# 3 #
#####
# Reboot, after which you shoiuld be able to login
# using 'ssh [email protected]'
$ sudo reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment