0

Problem:

I'm installing Ubuntu on Raspberry Pi for my robots, headless setup, only power and ethernet/wifi.

I'm cycling through images quickly, it's tedious to always be using a DHCP, make first access and change IP from inside the operating system via SSH, then reconnect with the right static IP.

What I tried:

I'm developing on windows, the ethernet configuration files are in a linux partitions that is not seen by windows out of the box.

The boot partition is convenient, and already has several settings I edit before plugging in the card (like GPIOs). I want to be able to setup a static IP by changing a config file on the BOOT partition.

I researched the topic, and no solution worked. e.g. the line on config.txt does nothing ip=192.168.0.5::192.168.0.1:255.255.255.0:rpi:eth0:off

Question:

Is there a way to setup a static IP on Ubuntu Desktop 22.04.1 LTS on config.txt or another file inside boot?

Can I place a script in BOOT that is executed the first time the Raspberry Pi is booted?

Answer: cmdline.txt ip=192.168.0.5::192.168.0.1:255.255.255.0:rpi:eth0:off As far as I can tell, it works by injecting through the tty serial interface the IP command that is processed and setup the ETH0 interface.

3
  • I fail to understand why you think you need to know the IP to ssh.
    – Milliways
    Sep 6, 2022 at 9:48
  • My laptop is 192.168.0.199 with 255.255.255.0. It will not connect to a virgin image using raspberrypi.local as address Sep 6, 2022 at 12:41
  • I haven't used current Ubuntu (because it requires a ludicrous amount of memory) but it is extremely unlikely the hostname is raspberrypi!
    – Milliways
    Sep 6, 2022 at 23:19

1 Answer 1

1

The parameter ip has to be inserted in the cmdline.txt file to set a static IP address at first startup.

ip=[IP-Address]::[Gateway IP]:[Subnetmask]:[Hostname]:[interface name]:[Autoconfig on/off]

[Example of /boot/cmdline.txt]
[some other stuff...]ip=192.168.0.2::192.168.0.1:255.255.255.0:rpi:eth0:off

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.