I'm setting up a Raspberry Pi Zero as an ethernet gadget using the instructions here.

That generally works but until I can log in to the Pi and configure it to use a static IP address it uses for its IP address a random one picked from the link-local range (169.254.0.1-169.254.255.255). Since I can't guess what that random address is I can't log in to the Pi to configure its static address or anything else.

This Pi is headless, so I can't log in to it directly to get its IP address or configure it to use a static address.

The Chromebook I'm configuring the Pi from doesn't support ZeroConf so I can't use raspberrypi.local instead of its IP address to reach the Pi.

Is there a way for me to set something up in the /boot partition of the Pi's microSD card to give it a static IP address on its first boot? Something similar to how wpa_supplicant.conf is copied from the /boot partition to /etc/wpa_supplicant?

If so, I could configure the static IP address for the Pi when I'm setting up its SD card. Needless to say, I can't modify that card's /rootfs from the Chromebook on which I'm doing this setup (Chrome OS can only mount ext4 partitions like /rootfs read-only).

Setting a static IP address from /boot would allow me to set up Pi Zeros using only Chromebooks, something which would be very useful when travelling and in classes.

  • 1
    While I realise another user did ask you to edit in details (this is fine if it's before it would invalidate answers), I've rolled your question back because: 1) Your edits invalidated answers that had already been added. This is inconsiderate of other users, and confusing to posterity; in future, ask a new question if you are substantially changing the criteria, 2) Your final version of the question is really about how to scan a network with a chromebook, and has nothing much to do with the Pi, or the (more or less unchanged) title of the question. That makes it off-topic here. – goldilocks Aug 2 at 12:31

If you can mount the root partition of your SD Card with the ext4 file system on a PC you simply can set a static ip address in /etc/dhcpcd.conf. There are some examples in it. You may consider to boot with a linux live system, e.g. from Debian or Ubuntu or SystemRescue or something else.

You can also use a network scanner running on your operating system. On Linux you can use nmap for example:

debian ~$ sudo nmap -sn 169.254.0.0/16 | grep -B 2 B8:27:EB

Here you will scan for devices from Raspberry Pi Foundation which MAC addresses start with B8:27:EB. Scanning about 65000 ip addresses in this example tooks a time. Maybe you can reduce the range if you can guess what subnet your ip address can be in, e.g. 169.254.7.0/24 with 255 ip addresses.

  • Thanks for the answer, unfortunately I'm trying to set up Pi's with Chromebooks, which can't mount ext4 file systems. It wouldn't make sense for me to maintain a Mac, Windows or Linux computer just to set up Pi's. On the other hand, I could use a pre-configured Pi for this (I'd set it up once with a borrowed Mac, Windows, or Linux system, then I wouldn't need Mac, Windows, or Linux other than the Linux on the Pi). I would however like to avoid if possible having to have a Pi around just to set up other Pi's. – dharcourt Apr 16 at 3:48
  • Thanks also for the nmap idea. Although I couldn't use nmap from the Chromebook, I might be able to use Chrome's chrome.socket APIs to create an extension that would achieve a similar purpose, searching 169.254.*.* addresses for Pi's newly set up on the local network. I'll investigate... – dharcourt Apr 16 at 3:50

A Chromebook supposedly has a shell in "developer mode" :)

If you can get to that (i.e. get the $ prompt), enter this at the$ prompt:

arp -a | grep --ignore-case b8:27:eb

But if your RPi Zero is not in your arp cache that won't yield anything useful. If that's the case, then create the following file in your editor, save it as pingpong.sh:

#!/bin/sh

: ${1?"Usage: $0 ip subnet to scan. eg '192.168.1.'"}

subnet=$1
for addr in `seq 0 1 255 `; do
#   ( echo $subnet$addr)
( ping -c 3 -t 5 $subnet$addr > /dev/null && echo $subnet$addr is Alive ) &
done

make it executable:

chmod 755 ~/pingpong.sh

and then execute it (use your network address here, not necessarily 192.168.1.:

~/pingpong.sh 192.168.1.

Your output should look like this:

    192.168.1.11 is Alive
    192.168.1.19 is Alive
    192.168.1.28 is Alive
    ...
    192.168.1.255 is Alive
    192.168.1.0 is Alive

Now, your RPi Zero should be in your Chromebook's arp cache, so run arp as before:

arp -a | grep --ignore-case b8:27:eb

And you should then see something like this:

? (192.168.1.19) at b8:27:eb:3a:b9:78 on en0 ifscope [ethernet]

And so, for this case, the IP address of your RPi Zero is 192.168.1.19

Hope that helps... this code was executed on my MacBook, not on a Chromebook, so YMMV.

  • @Ingo's solution might also work (I've not tried it), but of course you need a PC of some sort that can mount an EXT4 filesystem. Many Linux distros can, and I've heard Windoze PCs can do this, but again I've not tried it myself. I do know you can't mount EXT4 from OS X, and so that limits my range of approaches. – Seamus Apr 15 at 17:28
  • Thanks for the detailed answer, however I'm looking for a solution that would avoid running Chromebooks in developer mode as this would negate many of the security benefits of using Chromebooks. Additionally most Chromebooks running in schools and enterprises are enrolled in GSuite and have their developer mode disabled. – dharcourt Apr 16 at 3:58
  • 1
    You're welcome, and sorry that didn't help. If I could make a suggestion though: including all of your requirements in the OP would help us help you. I'd take another run at a solution, but frankly, after reading your comments to the two answers already provided, I am so unclear on what you're trying to do that I feel it would be a waste of time. – Seamus Apr 16 at 12:39
  • @dharcourt You might check whether arp is available in crosh without enabling developer mode. Many such commands are, and I have no way to test. – Bob Brown Apr 17 at 12:09
  • @BobBrown: arp is unfortunately not available in crosh. A list of crosh commands can be found online here and here, though commands are occasionally added and removed over time and may vary by Chromebook model. My Chromebook's crosh supports as subset of the commands listed online, and as far as I can tell none of those provides arp-like functionality. – dharcourt Apr 17 at 17:10

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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