Display and Configure an IP Address on Raspberry Pi
Learn how to use ifconfig and ip addr on Raspberry Pi to find IPv4 addresses and temporarily assign a manual address for local network testing.
An IP address identifies a device on a network. A Raspberry Pi can have a separate network configuration for each network interface, meaning a physical or logical connection used by the operating system. For example, Ethernet and Wi-Fi can each have their own address.
This lesson covers the legacy ifconfig command, the modern ip addr command, and a temporary manual IPv4 configuration for wired Ethernet. Basic terminal use, sudo, and local network concepts are useful prerequisites.
IP addresses and Raspberry Pi interfaces
An IPv4 address is a 32-bit network address written as four decimal numbers, such as 192.168.5.11. A subnet mask, such as 255.255.255.0, identifies which part of the address represents the local network.
A Raspberry Pi may have several interfaces:
| Interface name | Typical purpose | Address to expect | Notes |
|---|---|---|---|
eth0 | Wired Ethernet | A LAN address such as 192.168.5.11 | A common name for built-in wired Ethernet, although naming can differ. |
wlan0 | Wi-Fi | A LAN address assigned by the wireless network | A common Wi-Fi name; predictable interface names may use another name. |
lo | Loopback | 127.0.0.1 | Used for communication within the same Raspberry Pi and for diagnostics. |
The address 127.0.0.1 is the loopback address. It does not identify the Pi to other devices on the LAN. When looking for an address that another computer can use, inspect eth0, wlan0, or the actual interface name shown on your system.
Inspect interfaces with ifconfig
Run ifconfig without arguments to list active network interfaces and their details:
ifconfig
Depending on the operating system and version, the output can include Ethernet or Wi-Fi interfaces, the loopback interface, packet counters, MAC addresses, IPv4 information, and IPv6 information. A MAC address is a hardware-level identifier associated with an interface.
Look for the inet or older inet addr field. This is where the interface IPv4 address appears. The netmask field shows the subnet mask.
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.5.20 netmask 255.255.255.0 broadcast 192.168.5.255
ether aa:bb:cc:dd:ee:ff txqueuelen 1000
RX packets 1200 bytes 90000
TX packets 980 bytes 110000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
In this example, 192.168.5.20 is a usable LAN address for Ethernet. The 127.0.0.1 value belongs to lo and should be ignored when searching for the Pi's LAN address.
| Output field | Meaning | Example interpretation |
|---|---|---|
inet or inet addr | IPv4 address | 192.168.5.20 is the current address for that interface. |
netmask | Defines the local network portion of the IPv4 address | 255.255.255.0 commonly represents a network using the first three address groups. |
ether | MAC address | Useful when identifying an interface or creating a router DHCP reservation. |
UP/RUNNING | Interface state indicators | The interface is enabled and may have an active link. |
RX/TX counters | Received and transmitted packet statistics | Increasing counters can indicate network traffic. |
If an interface has no inet value, it may be disconnected, disabled, or not configured. A wireless interface might instead be named differently from wlan0, so inspect all interface names rather than assuming a name.
Find a wired or wireless address
Wired Ethernet
- Run
ifconfig. - Locate the
eth0section, or the wired interface name shown on your Pi. - Read the IPv4 value after
inetorinet addr. - Do not use
127.0.0.1from thelosection as the LAN address.
Wi-Fi
- Inspect the output for
wlan0or the actual wireless interface name. - Find its
inetfield. - Confirm that the interface is active and has received an address.
DHCP-assigned addresses
DHCP is a service, usually provided by the router, that automatically supplies an IP address, subnet information, and often gateway and DNS settings. This is how many Raspberry Pi systems receive their normal network configuration.
A DHCP address can change when its lease expires, the router restarts, or the Pi reconnects. Confirming the current address is therefore useful before connecting remotely with SSH or diagnosing a network problem. If you need a predictable address without manually configuring the Pi, create a DHCP reservation in the router using the interface's MAC address. The router will then normally offer the same address to that interface.
Temporarily assign an IPv4 address with ifconfig
You can select an interface, provide an IPv4 address, and specify its subnet mask with this command:
sudo ifconfig eth0 192.168.5.11 netmask 255.255.255.0
This assigns 192.168.5.11 with the mask 255.255.255.0 to eth0. The sudo prefix supplies the elevated privileges required to change interface settings.
- Confirm that the router's LAN uses the
192.168.5.xnetwork with the stated mask. - Confirm that
192.168.5.11is not already used by another device. - Run the command locally or through a connection where interruption is acceptable.
- Inspect the interface again:
ifconfig eth0
The assignment is normally temporary. It can disappear after reboot, an interface reset, or an action by NetworkManager, dhcpcd, or another network-management service.
Choose a safe manual address
The manual address must belong to the local network defined by the router and subnet mask. For example, with a router on 192.168.5.1 and mask 255.255.255.0, an address such as 192.168.5.11 is in the same local subnet, but it must still be unused.
- Do not choose an address already assigned to another device; an address conflict can make both devices unreliable.
- Do not assume that every home network uses
192.168.5.x. Check the router's actual LAN network first. - Changing only the address and mask does not necessarily configure a default gateway, the router used to reach other networks.
- It also does not necessarily configure DNS, the service that translates hostnames into IP addresses. Local communication may work while internet access or hostname lookup fails.
Modern commands and persistent configuration
The current Linux networking command suite is ip. To inspect one wired interface, run:
ip addr show eth0
Find the inet line and compare it with the IPv4 information shown by ifconfig. To see all interface names and addresses in a compact format, run:
ip -br addr
For a temporary test using the modern tool, an equivalent style is:
sudo ip addr add 192.168.5.11/24 dev eth0
Both command-line approaches are tests or immediate changes, not a complete persistent network configuration. Depending on the Raspberry Pi OS version, persistent settings may be managed by NetworkManager, dhcpcd, or other system network configuration tools. Use the mechanism supported by the installed system rather than configuring several managers for the same interface.
| Method | Survives reboot | Best use case | Important limitation |
|---|---|---|---|
ifconfig manual assignment | No | Quick legacy compatibility test | May be overwritten by DHCP or another network service. |
ip addr manual assignment | No | Modern command-line test | Does not by itself provide a complete gateway and DNS configuration. |
| DHCP reservation | Usually yes from the device's perspective | Keeping a predictable address with low maintenance | Requires access to the router and depends on that router's DHCP service. |
| Operating-system network configuration | Yes | A deliberate static-address setup | Configuration method differs by Raspberry Pi OS version and network manager. |
Verify the address and test connectivity
After discovering or assigning an address, inspect the target interface again:
ip addr show eth0
ifconfig eth0
Check whether the address is present, the mask is correct, and the interface is enabled. Then test a known device on the same LAN, such as the router:
ping -c 4 192.168.5.1
Replace the example address with the actual local router or another known reachable device. If local testing succeeds but internet access fails, inspect the routing table:
ip route
A usable configuration normally includes a default route. Test the gateway by IP before testing a hostname; this separates routing problems from DNS problems.
Troubleshooting common results
ifconfig is not found
Use ip addr, which is the preferred modern replacement. If a script or lesson specifically requires ifconfig, install the distribution package that provides it, commonly named net-tools.
No IPv4 address appears for eth0 or wlan0
Check the Ethernet cable, Wi-Fi association, interface state, and DHCP availability. Use ip addr and the system's network status tools to determine whether the interface is disabled or simply has not received a lease.
The only address is 127.0.0.1
That means only loopback is configured. Check eth0 or wlan0, restore the physical or wireless connection, and obtain an address from DHCP or configure a suitable local address.
The Pi becomes unreachable after assignment
The address may be on the wrong subnet, already in use, or different from the address targeted by the SSH client. Use local console access if possible, verify the router network and mask, choose an unused address, or return to DHCP. Then reconnect using the current address.
The interface has an address but cannot reach the internet
Check ip route for a default gateway. Test the gateway by IP, then review DNS settings after IP connectivity is confirmed. Also verify that the address and mask match the LAN.
The address disappears after reboot
This is expected for an ifconfig or ip addr test assignment. Use a DHCP reservation or the supported persistent network configuration method for the installed Raspberry Pi OS version.
Key points
- Each interface can have its own address;
eth0is commonly wired,wlan0commonly means Wi-Fi, andlois loopback. - Read the IPv4 address from
inetorinet addr, and do not mistake127.0.0.1for a LAN address. - DHCP is convenient but its address can change unless the router reserves it.
sudo ifconfig eth0 192.168.5.11 netmask 255.255.255.0is a temporary wired-address example.- A manual address must be in the correct subnet and must not conflict with another device.
- An address alone may not provide a default gateway or DNS.
- Prefer
ip addrfor modern inspection, and use DHCP reservations or supported operating-system configuration for durable addressing.