rje
Posts: 1
Joined: Fri Jun 08, 2018 3:00 pm

Static IPs for 45 Raspberry Pis!

Fri Jun 08, 2018 7:14 pm

I have 45 Raspbian images, for a hackathon.

I'd like to set a static IP for each of them; however, I would prefer NOT to have to boot each one separately.

I tried adding ip=192.168.8.xx to cmdline.txt file in the boot partition, to no avail. In fact, when I do that, I *think* the Pi can't be reached at all.

Any ideas? Or am I going to have to boot 45 images?

Regards,

Robert

P.S. Raspbian details:

Code: Select all

[email protected]:~/sens/vl53l0x $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
NAME="Raspbian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

User avatar
DougieLawson
Posts: 35378
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Static IPs for 45 Raspberry Pis!

Fri Jun 08, 2018 10:31 pm

Do you know the serial number for each RPi? Or would you need to boot each one to discover that?
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

ejolson
Posts: 3072
Joined: Tue Mar 18, 2014 11:47 am

Re: Static IPs for 45 Raspberry Pis!

Sat Jun 09, 2018 3:46 am

rje wrote:
Fri Jun 08, 2018 7:14 pm
I'd like to set a static IP for each of them; however, I would prefer NOT to have to boot each one separately.
Maybe you could edit dhcpcd.conf directly using an SD card reader for each one without booting?

User avatar
DougieLawson
Posts: 35378
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Static IPs for 45 Raspberry Pis!

Sat Jun 09, 2018 7:45 am

ejolson wrote:
Sat Jun 09, 2018 3:46 am
rje wrote:
Fri Jun 08, 2018 7:14 pm
I'd like to set a static IP for each of them; however, I would prefer NOT to have to boot each one separately.
Maybe you could edit dhcpcd.conf directly using an SD card reader for each one without booting?
If we know the serial nunbers we can create a single /etc/dhcpcd.conf for all raspberries, it needs predictable names active to discriminate between each interface.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
B.Goode
Posts: 7870
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Static IPs for 45 Raspberry Pis!

Sat Jun 09, 2018 9:59 am

I have 45 Raspbian images, for a hackathon.

I'd like to set a static IP for each of them;

Not trying to dodge the question, but a couple of possibly relevant follow-up questions -

Who will be providing/supporting the network infrastructure in the Hackathon venue? Is it provided by the venue, or will you be taking your own 'network in a box'? Relevant because you need to know that the static addresses you assign are valid for the network being used, and that the addresses are allocated to you and not clashing with other users.

Why do you need static addresses?

User avatar
bensimmo
Posts: 4072
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Static IPs for 45 Raspberry Pis!

Sat Jun 09, 2018 10:05 am

Use an AP/Switch/Router and have that set them for you, uplink from there if you need to ?

fred44nl
Posts: 292
Joined: Sat Jun 25, 2016 11:59 am
Location: Scharendijke, NL

Re: Static IPs for 45 Raspberry Pis!

Sat Jun 09, 2018 10:17 am

bensimmo wrote:
Sat Jun 09, 2018 10:05 am
Use an AP/Switch/Router and have that set them for you, uplink from there if you need to ?
that's what I would go for.
boot them all up, and make ip-address reservations in the dhcp-server, based on the mac-addresses.
headless RPi 3B running from usbhdd.

User avatar
bensimmo
Posts: 4072
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Static IPs for 45 Raspberry Pis!

Sat Jun 09, 2018 10:43 am

It all depends on the reasoning and feasibility though.

epoch1970
Posts: 3070
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Static IPs for 45 Raspberry Pis!

Sat Jun 09, 2018 11:54 am

Perhaps via a script in rc.local or something like that in addition to cmdline.txt, generating dhcpcd.conf or some systemd network interface?
E.g.

Code: Select all

$ cat /proc/cmdline ; X=$(cat /proc/cmdline); X=${X##*elevator=}; X=${X%% *}; echo ; echo "Elevator -> [$X]"
8250.nr_uarts=0 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708_fb.fbswap=1 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000  bcm2835_wdt.heartbeat=15 dwc_otg.lpm_enable=0 console=ttyS0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

Elevator -> [deadline]
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

pksato
Posts: 295
Joined: Fri Aug 03, 2012 5:25 pm
Location: Brazil

Re: Static IPs for 45 Raspberry Pis!

Sat Jun 09, 2018 12:17 pm

You need to each SD card have a unique IP or each board have a unique IP?
For SD, a symlink on /etc/network/interfaces.d to a file on /boot. I not sure if work.

For each board, need to use some unique information from hardware, board serial, mac address, eeprom, etc...
And use a init script or some hook on interfaces or other network configuration mechanism.
But, is more easy to setup a dhcp server, on some router or other RPi.

mikerr
Posts: 2768
Joined: Thu Jan 12, 2012 12:46 pm
Location: UK
Contact: Website

Re: Static IPs for 45 Raspberry Pis!

Sat Jun 09, 2018 12:57 pm

A more sensible approach might be to just have unique hostnames and access via those.

Raspbian has mDNS, so will respond to hostname.local (raspberrypi.local by default)
Android app - Raspi Card Imager - download and image SD cards - No PC required !

ejolson
Posts: 3072
Joined: Tue Mar 18, 2014 11:47 am

Re: Static IPs for 45 Raspberry Pis!

Sat Jun 09, 2018 5:58 pm

mikerr wrote:
Sat Jun 09, 2018 12:57 pm
A more sensible approach might be to just have unique hostnames and access via those.

Raspbian has mDNS, so will respond to hostname.local (raspberrypi.local by default)
I suspect the idea is for each SD card to have a unique IP address, otherwise you could simply set up a DHCP server with permanent leases keyed to MAC addresses.

Milliways
Posts: 408
Joined: Fri Apr 25, 2014 12:18 am
Location: Sydney, Australia

Re: Static IPs for 45 Raspberry Pis!

Sun Jun 10, 2018 6:17 am

The first question I would ask is WHY?

Over a 40 year career as an engineer I have been asked to implement all sorts of improbable "solutions" - in most cases these could be done (often with significant effort) but it is usually easier/cheaper to actually solve the REAL problem, rather than someones idea of a solution.

Static IP addresses are invariably the WRONG solution. (I am old enough to remember the days before DHCP when it was necessary, but a nightmare.)

User avatar
DougieLawson
Posts: 35378
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Static IPs for 45 Raspberry Pis!

Sun Jun 10, 2018 8:29 am

Milliways wrote:
Sun Jun 10, 2018 6:17 am

Static IP addresses are invariably the WRONG solution. (I am old enough to remember the days before DHCP when it was necessary, but a nightmare.)
Fair comment. /etc/hosts vs a DNS server follows the same argument.

One solution would be a 46th Raspberry (or any other Linux machine) on the network running a local DHCP server (dnsmasq or isc-dhcp-server).
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
bensimmo
Posts: 4072
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Static IPs for 45 Raspberry Pis!

Sun Jun 10, 2018 9:30 am

DougieLawson wrote:
Sun Jun 10, 2018 8:29 am
Milliways wrote:
Sun Jun 10, 2018 6:17 am

Static IP addresses are invariably the WRONG solution. (I am old enough to remember the days before DHCP when it was necessary, but a nightmare.)
Fair comment. /etc/hosts vs a DNS server follows the same argument.

One solution would be a 46th Raspberry (or any other Linux machine) on the network running a local DHCP server (dnsmasq or isc-dhcp-server).
At that point, set it up as a PiServer and no need to worry about images again.
Could also move to Stretch with one image rather than 45 of them.


Although I want to know what you're doing at the Hackathon with the 45 Pi :-)

pfletch101
Posts: 446
Joined: Sat Feb 24, 2018 4:09 am

Re: Static IPs for 45 Raspberry Pis!

Sun Jun 10, 2018 3:50 pm

Milliways wrote:
Sun Jun 10, 2018 6:17 am
Static IP addresses are invariably the WRONG solution. (I am old enough to remember the days before DHCP when it was necessary, but a nightmare.)

One proviso: I would entirely agree with your comment if you are talking about a device specifying its own fixed IP address. It is, however, frequently useful and/or necessary to configure a router to assign specific 'fixed' IP addresses to certain devices based on their MAC addresses.

ejolson
Posts: 3072
Joined: Tue Mar 18, 2014 11:47 am

Re: Static IPs for 45 Raspberry Pis!

Sun Jun 10, 2018 5:26 pm

bensimmo wrote:
Sun Jun 10, 2018 9:30 am
Although I want to know what you're doing at the Hackathon with the 45 Pi :-)
It would be nice if there was a visible indication when a user is banned. That way people would know whether a one-post thread like this was genuine or simply the registration post of a spammer.

Since there is no indication when a user is banned, it would be helpful if the person who made the original post could give feedback on what they did and how the hackathon turned out.

Return to “Beginners”