Home | Miscellaneous | Raspberry Pi | Set Address
Charles Varvayanis Logo
Charles Varvayanis
Computer and Communication Systems
Since 1990
(209) 586-3782
charles@varvayanis.com
Charles Varvayanis Logo

How to Set Raspberry Pi IP Address

Step-by-step instructions for setting the Raspberry Pi IP Address.

These procedures apply to Raspberry Pi 5, 4 or 3 with Raspberry Pi OS (64-Bit), (32-Bit) or (Legacy, 32-Bit).


General Notes



1. General:  The procedures below are optimized for determining the IP Address of a Raspberry Pi 5, 4 or 3 with Raspberry Pi OS (64-Bit), (32-Bit) or (Legacy, 32-Bit).

2. Internet access during setup:  Many of the steps below assume and require the target Raspberry Pi is connected to a network with access to the Internet.


Notice about updates, upgrades and installations failing due to repository or network congestion or outages


Occasionally updates, upgrades and installations fail due to repository or network congestion or outages.  Sometimes there is an appropriate message saying as such, sometimes a missing file is reported, and sometimes there is just a failure message without an explanation.  When this occurs, simply run the command again.  If that does not solve the issues immediately, try again later.



Connect to the target Raspberry Pi


Connect to the target Raspberry Pi using Raspberry Pi Connect Remote shell or Raspberry Pi Connect Screen share and open a Terminal window.

https://www.raspberrypi.com/software/connect
  - or -

Connect directly to the target Raspberry Pi via a Display, Keyboard and Mouse, then open a Terminal window.

  - or -

Use SSH via a tool such as PuTTY to connect to the Raspberry Pi.

https://putty.software/
https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
https://www.putty.org
Connect using the IP address or URL of the target Raspberry Pi.
Note:  The first time a connection is made, a security warning may be displayed | Yes


For using SSH above, determine the target Raspberry Pi IP Address:


Use an IP Scanner tool such as Advanced IP Scanner on a PC or alike to locate the DHCP IP Address assigned to the Raspberry Pi.

https://www.advanced-ip-scanner.com
  - or -

Connect directly to the target Raspberry Pi via a Display, Keyboard and Mouse, then open a Terminal window.

sudo hostname -I
  - or -

Connect to the target Raspberry Pi using Raspberry Pi Connect Remote shell or Raspberry Pi Connect Screen share and open a Terminal window.

sudo hostname -I
  - or -

Login to your router and examine the DHCP assignments, sometimes labeled "Connected Devices" or similar.




Update Raspberry Pi OS and Components


Download latest package lists

sudo apt-get update -y

Download and install updated listed packages

sudo apt-get upgrade -y



Change the Raspberry Pi IP address and network settings using the Rasberry Pi Desktop Interface (GUI), NetworkManager User Interface (UI), or Command Line Interface (CLI)


Note: While the steps below are specific to setting the IP Address of the Ethernet Port, they can be used for setting the IP Address of a Wi-Fi connection by substituting the references to "Wired Connection 1" with your Wi-Fi Connection.


Update Raspberry Pi OS and Components


Download latest package lists

sudo apt-get update -y

Download and install updated listed packages

sudo apt-get upgrade -y



Enable NetworkManager on Raspberry Pi OS (Legacy) only.  Note:  NetworkManager is already enabled by default on Raspberry Pi OS (64-bit) and (32-Bit).


  Enable NetworkManager

  sudo raspi-config

  Advance Options | [Enter] | Network Config | [Enter] | NetworkManager | [Enter] | OK | [Enter] | Finish | [Enter] | Would you like to reboot now? | Yes | [Enter]
  Note 1:  The DHCP assigned IP Address of the Raspberry Pi may change and need to be located again.
  Note 2:  If TeamViewer is installed, the TeamViewer ID of the Raspberry Pi may change and need to be obtained again.




Note:  The Subnetwork Mask is expressed in Slash Notation along with an IP Address in certain areas of this section.


Network Subnetwork Mask and Slash Notation Relationships


Class  Mask                      Slash  Addresses  Nodes       Usable Addresses
A255.000.000.000/8167772161677721416777213
B255.255.000.000/16655366553465533
B255.255.128.000/17327683276632765
B255.255.192.000/18163841638216381
B255.255.224.000/19819281908189
B255.255.240.000/20409640944093
B255.255.248.000/21204820462045
B255.255.252.000/22102410221021
B255.255.254.000/23512510509
C255.255.255.000/24256254253
C255.255.255.128/25128126125
C255.255.255.192/26646261
C255.255.255.224/27323029
C255.255.255.240/28161413
C255.255.255.248/29865
C255.255.255.252/30421
C255.255.255.254/31200
C255.255.255.255/32100


Change the Raspberry Pi IP address and network settings using the Rasberry Pi GUI (Desktop)


Click on the two arrows facing up and down on the right side of the Task Bar at the top of the Raspberry Pi desktop
Click on "Advanced Options" | "Edit Connections..."
Doubke Click on "Ethernet" | "Wired connection 1"
Click on the "IPv4 Settings" Tab
Click on these fields to edit them:
  "Method" | Manual
  "Address" - Your Rspbrry Pi IP Address - Example:  192.168.0.25
  "Netmask" - See the section above "The Subnetwork Mask is expressed in Slash Notation..." - Example:  /24
  "Gateway" - Typicaly the network router LAN IP Address - Example:  192.168.0.1
  "DNS servers" - DNS servers are seperated by space characters. - Example:  8.8.8.8 8.8.4.4
Click on the "Save" Button
X out of the "Network Connections" window


- or -


Change the Raspberry Pi IP address and network settings using the NetworkManager User Interface (UI)


Open the NetworkManager User Interface (UI)

sudo nmtui

Edit a connection | [Enter] | Wired Connection 1 | [Enter]
Change these fields  (Note:  Use [Tab] to move around the window, [Enter] to select, and [Esc] to back out of a window):
  IPv4 CONFIURATION | <Automatic> | [Enter] | Manual | [Enter] | <Show> | [Enter]
  Addresses | <Add...> | [Enter] | <YourRaspberryPiIPAddress>/<YourNetworkSubnetworkMask> - Example:  192.168.0.25/24 | [Enter]
    (The Subnetwork Mask is expressed in Slash Notation along with the IP Address.)
  Gateway | <YourNetworkDefaultGatewayIPAddress> (Typicaly the network router LAN IP Address) - Example:  192.168.0.1 | [Enter]
  DNS Servers | <Add...> | [Enter] | <DNSServer1> - Example:  8.8.8.8 | [Enter]
  DNS Servers | <Add...> | [Enter] | <DNSServer2> - Example:  8.8.4.4 | [Enter]
  OK | [Enter]  (Note:  [Tab] to bottom of the window)
[Esc] | [Esc]

Restart the connection to begin using the new settings

sudo nmcli con up "Wired connection 1"


- or -


Change the Raspberry Pi IP address and network settings using NetworkManager Command Line Interface (CLI)


Show all network connections

sudo nmcli con show
Note:  "Wired connection 1" is the default Ethernet connection name and is assumed in the following commands.

Set IP Address

(The Subnetwork Mask is expressed in Slash Notation along with the IP Address.)
sudo nmcli con mod "Wired connection 1" ipv4.addresses <YourRaspberryPiIPAddress>/<YourNetworkSubnetworkMask>
Example:
sudo nmcli con mod "Wired connection 1" ipv4.addresses 192.168.0.25/24

Set the Gateway Address

(Typicaly the Gateway Address is network router LAN IP Address)
sudo nmcli con mod "Wired connection 1" ipv4.gateway <YourNetworkDefaultGatewayIPAddress>
Example:
sudo nmcli con mod "Wired connection 1" ipv4.gateway 192.168.0.1

Set the DNS Servers

(Use spaces to seperate multiple domain name server addresses)
sudo nmcli con mod "Wired connection 1" ipv4.dns" <DNSServer1> <DNSServer2> <DNSServer...>"
Example:
sudo nmcli con mod "Wired connection 1" ipv4.dns "8.8.8.8 8.8.4.4"

Set the Addressing Mode to Manual (Static)

sudo nmcli con mod "Wired connection 1" ipv4.method manual

Restart the connection to begin using the new settings

sudo nmcli con up "Wired connection 1"

Display the IP Address, Gateway, DNS Servers and Addressing Mode (Optional)

sudo nmcli -g ip4.address,ipv4.gateway,ip4.dns,ipv4.method connection show "Wired connection 1"

Display the profile so all parameters can be reviewed (Optional)

sudo nmcli -p con show "Wired connection 1"



Remove packages that were automatically installed and are no longer required

Occasionally excess update, upgrade and installation packages install automatically, but are no longer required.  These can be removed automatically.

Automatically detect and remove packages no longer required

sudo apt autoremove -y



Charles Varvayanis
Sonora, CA  95370
e-mail:  charles@varvayanis.com
Phone:  (209) 586-3782
Fax:  (209) 586-3761
Business Card (PDF 153 KB) PDF
www.varvayanis.com
www.varvayanis.com

© 2025 Charles Varvayanis.  All rights reserved.