I'm putting multiple RPIs onto a subnet together connected via ethernet (all of them headless) using a switch and I want to be able to know what their IPs are when I first boot them. They won't be connected to a router or anything so they won't be assigned an IP.

Ideally I want to be able to edit /etc/dhcpcd.conf from the boot drive on the SD cards directly before booting the Pis for the first time. Alternatively, is there another way to set a static IP address from the boot drive?

  • You are putting multiple RPIs onto a subnet together connected via ethernet. So you have at least a switch, right?
    – Ingo
    Jul 9, 2018 at 13:09
  • @Ingo yes, I'm using a switch
    – Matt
    Jul 9, 2018 at 16:16

6 Answers 6


Normally I advise against static IP addresses, but an isolated network is one of the few valid use cases.

You can connect to the Pi over a direct Ethernet link to the Pi (not via a switch or router) using the Link-local address, although discovering this can be problematic.

You can easily connect from Linux and OS X with ssh [email protected] (the default hostname is raspberrypi) This should work with popular GUI ssh programs. This is sometimes problematic with some versions of Windows and networks which use .local in a non-standard way. (See https://en.wikipedia.org/wiki/.local)

The other alternative is to assign an IP by including something like ip= in cmdline.txt. See https://elinux.org/RPi_cmdline.txt

I have not used the last in a modern Raspbian using dhcpcd, but it should still work, and should be replaced by a normal configuration.

PS accessing ext4 partitions from macOS is difficult, since the introduction of SIP. There may be 3rd party (paid) solutions which work.

  • Thanks! I tried adding ip= to the end of cmdline.txt from the boot partition on the SD card directly and it didn't seem to take affect. Is there another step I am missing?
    – Matt
    Jul 8, 2018 at 5:09
  • @Matt Unfortunately I can provide no other ideas. I haven't used this for over 4 years (when Raspbian used Debian networking) - now I use raspberrypi.local if I need direct connection. You should provide more detail of EXACTLY your configuration. NOTE ssh is NOT enabled by default, and needs ssh on the boot partition.
    – Milliways
    Jul 8, 2018 at 5:31
  • I just tested the ip=... option in cmdline.txt with latest raspios release, it works correctly
    – ephestione
    Mar 14, 2021 at 10:03
  • @Matt try the following ip= where is your gateway and is network mask. It worked for me with a fresh rasp pi 64 bit image - no keyboard and monitor
    – aderesh
    Mar 20, 2022 at 3:47

SD card for raspibian OS has two partitions /boot and /rootfs. Using SD card reader, I mounted the partitions onto my system with ubuntu OS. For setting up static IP address edit the file dhcpcd.conf with root privileges.

  $ sudo nano ~/rootfs/etc/dhcpcd.conf

Add the static IP details in the file.

   interface eth0    
   static ip_address =

Save (Ctrl+x, Press y).

Since I was using headless setup ethernet cable connection between RPi and my laptop, I needed ssh to be enabled as default. To enable ssh, create an empty file named ssh in the /boot partition

   $ cd /boot
   $ touch ssh

Unmount partitions. Plug the SD card back to the raspberry pi board. Now the device (with username "pi", here) is accessible through ssh from the system.

$ sudo ssh [email protected]`

(My system was set with static IP of

I found this example of how to do headless IP address setup for raspibian on raspberry pi with ubuntu in the following link. https://foolsvilla.blogspot.com/2020/03/how-to-set-static-ip-address-for.html . It worked for me.


We should be clear on terminology. When you say boot drive, are you referring to the SD card? That's fine, but know that there is a /boot partition on the SD card also (a *FAT filesystem), and it has a role in configuring some aspects of RPi when it is first booted. Unfortunately, setting static IP addresses can't be done in the /boot folder. However: If you have an RPi 4, you can configure the bootloader skip the DHCP process entirely, and assign a static IP address.

To edit the /etc/dhcpcd.conf file, you'll need to mount the root partition (/) of the boot drive (the SD card) using a system that can read the ext4 filesystem (e.g. you could remove it from your RPi, and mount it using an Ubuntu laptop). Another way would be to boot your RPi using a "live linux" thumb drive (Debian or Linux), and edit the file in situ.

  • yes I meant the SD card. Do you know if there is any way to read the ext4 filesystem from Mac?
    – Matt
    Jul 7, 2018 at 20:19
  • I wouldn't try it on my Mac (REF), but there are some commercial tools that claim to do this (example), and here's a github page with some info.
    – Seamus
    Jul 7, 2018 at 20:34

Here is an alternative solution to changing files on the ext4 SD-card, as it was suggested by Seamus:

  1. First you should connect your Raspberry Pi with another computer via Ethernet cable.

  2. After connecting your Raspberry Pi with another device (without a running DHCP server) via ethernet cable, on a new Raspbian installation your Raspberry Pi will have a self assigned link-local IP-address in the range of to

  3. Now the Ethernet interface on your computer also needs an IP address in the same subnet as the Raspberry Pi. If it did not self assign a link-local IP-address, you should set it yourself by choosing any in the range of to
    On Linux, e.g. use sudo ifconfig eth0

  4. Now you can directly ssh into your Raspberry Pi by

    ssh [email protected]

    and change the /etc/dhcpcd.conf file remotely.

If the raspberrypi.local addressing does not work, you need to search for the IP-address of your Raspberry Pi with a network scanner. On a Linux machine you can e.g. use arp-scan:

sudo arp-scan –interface=eth0

After finding the IP-address, you can now ssh into your Raspberry Pi.


Another possibility is to move the /etc/dhcpcd.conf file to the boot partition and then symlinking to it from the /etc directory by issuing

# mv /etc/dhcpcd.conf /boot/dhcpcd.conf
# ln -s /boot/dhcpcd.conf /etc/dhcpcd.conf

Then you have the config file laying around in the boot partition and can access it from e.g. a Windows computer.


If you want a full headless setup of a static IP, you can update cmdline.txt in boot volume by adding the following string: ip= where

  • your PI's static IP
  • your gateway (is a pretty much default value for all home networks)
  • your netmask (is a pretty much default value for all home networks)

This worked for my completely headless setup (no monitor, no keyboard connected to PI) in Linux raspberrypi 5.10.92-v8+ #1514 SMP PREEMPT Mon Jan 17 17:39:38 GMT 2022 aarch64 GNU/Linux

Make sure your static IP address is not being used or is not in the DHCP address space (usually

My config cmdline.txt:

console=serial0,115200 console=tty1 root=PARTUUID=cb15ae4d-02 rootfstype=ext4 fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh ip=

Note: make sure you have one space between previous command and pi=..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.