I know we can have raspbian connect to local wifi if we copy wpa_supplicant file to location were boot.txt is in sd card, and even enable ssh by copying ssh file to the same location, but how can we also assign a static ip at the inital boot?


2 Answers 2


There is no simple way to configure a static ip address at the first initial boot after flashing Raspbian to the SD Card. You have to boot at least one time, login and configure the static ip address.

On the first boot there is a script running that expands the root partition to the size of the SD Card and do other essential initialization things. You will find the call of the script with init=/usr/lib/raspi-config/init_resize.sh in boot/cmdline.txt at the end of the line but only if you don't have booted the fresh flashed image. After the first boot the entry is removed. You may try to modify this script to setup a static ip address, but as already said: it isn't an easy task. You may have a look at Use /boot/cmdline.txt for creating first-boot script about your problem. There are also some links to github projects which address your problem.


Edit /boot/cmdline.txt and append to the end of the line a space and then:


(Substituting whatever static IP address you want for the example above.)

On my raspberry pi, which I just did this with, the resulting cmdline.txt looks like:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait ip=

I originally learned of this here:


Which said to use a more complex version:


However, after doing some googling on cmdline.txt and "ip=", I found several examples of the simpler version, so I tried it and it worked.

While searching, I found this page, which seems to have more info on the options, though I'm not certain it's specific to Raspberry PI OS:



This parameter tells the kernel how to configure IP addresses of devices and also how to set up the IP routing table. It was originally called nfsaddrs', but now the boot-time IP configuration works independently of NFS, so it was renamed to ip' and the old name remained as an alias for compatibility reasons.

I'm on Raspberry PI OS 11, aka "bullseye", according to "lsb_release -a".

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.