patfenton
Posts: 11
Joined: Thu May 13, 2021 8:51 am
Location: Dublin

Cloned PIs won't work on same LAN

Thu May 13, 2021 9:14 am

I have two RPi 3 Model B + devices that both use static IP addresses using ethernet ports. I cloned the SD card from the first Pi using the SD copier software provided with Raspbian. I inserted the cloned SD card into the second Pi. I changed the hostname, password and static IP address on the second Pi system.
The second Pi works perfectly on a different network but will not work on the same network as the first Pi. What do I have to do to make both work on the same network with static IP addresses?

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

Re: Cloned PIs won't work on same LAN

Thu May 13, 2021 3:15 pm

I think you'd need to re-generate /etc/machine-id.
It's a DBus/systemd thing. No 2 machines are supposed to have the same machine ID.
There is a procedure to re-generate the file, unfortunately I'm not too sure what's applicable on Raspios. https://unix.stackexchange.com/question ... machine-id
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

User avatar
thagrol
Posts: 5015
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Cloned PIs won't work on same LAN

Thu May 13, 2021 5:56 pm

Do both Pi have the same MAC addresses?

All Pi mdels prior to the 4B derive their MAC addresses from their serial numbers.

Serial numbers are randomly generated at the factory.

Enough Pi have been sold that duplicate serial numbers now exist.

The chance is small but it's still a chance.
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

patfenton
Posts: 11
Joined: Thu May 13, 2021 8:51 am
Location: Dublin

Re: Cloned PIs won't work on same LAN

Thu May 13, 2021 7:18 pm

Thanks tagrol, but the MAC addresses are different.

bls
Posts: 1485
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA

Re: Cloned PIs won't work on same LAN

Thu May 13, 2021 7:22 pm

Stepping back an inch or two, it's not clear to me how cloning a system for a new machine is different than burning two SD cards from the same IMG.

What am I missing?

As far as the OP's problem, you said that the second pi "will not work on the same network as the first pi". Could you expand (with as much detail as possible) on how it doesn't work? If there are real signs, like "can't get an IP address", some logs would be super-helpful.
Pi tools:
Quickly and easily build customized-just-for-you SSDs/SD Cards: https://github.com/gitbls/sdm
Easily run and manage your network's DHCP/DNS servers on a Pi: https://github.com/gitbls/ndm
Easy and secure strongSwan VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

patfenton
Posts: 11
Joined: Thu May 13, 2021 8:51 am
Location: Dublin

Re: Cloned PIs won't work on same LAN

Thu May 13, 2021 8:03 pm

Thanks epoch1070, that didn't work for me. You were correct that the machine-id was the same on the two devices.
I removed /etc/machine-id and regenerated it using systemd-machine-id-setup.
That worked and it also changed the symlink in /var/lib/dbus/machine-id.
But network still not working after a reboot with the original Pi also on the same LAN.
Funny though, I can ping to it but not ssh.
Ethernet just not getting set up properly.

patfenton
Posts: 11
Joined: Thu May 13, 2021 8:51 am
Location: Dublin

Re: Cloned PIs won't work on same LAN

Thu May 13, 2021 8:12 pm

I don't know, bls, but there are other posts on this issue on the net. Just none of the solutions they offer work. Basically, the advise is not to clone machines and expect them to work together!!
I can ping to the cloned machine when on the same LAN as the original, but not ssh or VNC. Both work perfectly when I take the original Pi off the LAN. They just won't work together.
When I do an ifconfig, eth0 has no IP address.

buchalvi
Posts: 28
Joined: Thu Mar 04, 2021 12:24 pm

Re: Cloned PIs won't work on same LAN

Thu May 13, 2021 8:17 pm

what's the output of the command

Code: Select all

hostnamectl
on both the Pis. In addition to Machine IDs, could you confirm if Boot IDs are different as well?
\/
Want to Transform an RPi board into a secure router?

Want to try an alternative OS to OpenWrt?

Try
https://www.github.com/mahsank/pi-router
\/

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 6277
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: Cloned PIs won't work on same LAN

Thu May 13, 2021 8:26 pm

bls wrote:
Thu May 13, 2021 7:22 pm
Stepping back an inch or two, it's not clear to me how cloning a system for a new machine is different than burning two SD cards from the same IMG.

What am I missing?

...
Given that, following the completion of the first install process various settings (hostname, passwords etc.) will have been changed and the original "image" expanded to fill the uSD card the clone will not be exactly the same as said image. Given that no two uSD cards of the same nominal size are exactly the same physical size strictly-speaking they will differ, albeit "in a small way". The main advantage of cloning is that there may be post-first-install settings that are needed (common to) all machines which, if cloning is used, only have to be set once. However, given that many of such settings can now be pre-defined via the newest version of the Raspberry Pi Imager tool's advanced options that "advantage" may be minimal for some setups. (Whether other tools provide similar options ....?) The cloning tool also provides an easy way of copying a working uSD card system to a USB-booted SSD-based system: http://www.cpmspectrepi.uk/raspberry_pi ... lP400.html
(FWIW, some notes on the various stages of how I got to where I am with the P400 I'm currently posting from)
Trev.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, and a A+) but Buster on the P4B's & P400. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

patfenton
Posts: 11
Joined: Thu May 13, 2021 8:51 am
Location: Dublin

Re: Cloned PIs won't work on same LAN

Thu May 13, 2021 8:37 pm

These are different, buchalvi.

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

Re: Cloned PIs won't work on same LAN

Thu May 13, 2021 10:21 pm

Looking at /var/log/syslog (dhcpcd messages, esp.) would help...
Perhaps try “sudo dhcpcd -k eth0” then “sudo dhcpcd eth0” or reboot. “-k” tells dhcpcd to release any IP address it might try to request again (leases are saved in /var/lib/misc IIRC)
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

jj_0
Posts: 129
Joined: Wed Jul 11, 2012 7:07 am

Re: Cloned PIs won't work on same LAN

Fri May 14, 2021 2:52 pm

What happens if you swap the SD-cards of both Pi's is it then the other Pi that has the issue?

User avatar
butchkemper
Posts: 84
Joined: Sat Jul 22, 2017 8:03 pm
Location: Sachse, Texas USA

Re: Cloned PIs won't work on same LAN

Fri May 14, 2021 6:19 pm

patfenton wrote:
Thu May 13, 2021 8:03 pm
Thanks epoch1070, that didn't work for me. You were correct that the machine-id was the same on the two devices.
I removed /etc/machine-id and regenerated it using systemd-machine-id-setup.
That worked and it also changed the symlink in /var/lib/dbus/machine-id.
But network still not working after a reboot with the original Pi also on the same LAN.
Funny though, I can ping to it but not ssh.
Ethernet just not getting set up properly.
I believe this post contains the answer. The pi will respond to a ping so the ethernet connection is correct.

The ssh does not work so I suspect this is the problem. What error message do you receive when you attempt to initiate a SSH session?

Butch

buchalvi
Posts: 28
Joined: Thu Mar 04, 2021 12:24 pm

Re: Cloned PIs won't work on same LAN

Fri May 14, 2021 9:16 pm

You can increase verbosity while connecting via SSH.

Code: Select all

shh -vvv 
\/
Want to Transform an RPi board into a secure router?

Want to try an alternative OS to OpenWrt?

Try
https://www.github.com/mahsank/pi-router
\/

User avatar
thagrol
Posts: 5015
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Cloned PIs won't work on same LAN

Fri May 14, 2021 9:56 pm

butchkemper wrote:
Fri May 14, 2021 6:19 pm
patfenton wrote:
Thu May 13, 2021 8:03 pm
Thanks epoch1070, that didn't work for me. You were correct that the machine-id was the same on the two devices.
I removed /etc/machine-id and regenerated it using systemd-machine-id-setup.
That worked and it also changed the symlink in /var/lib/dbus/machine-id.
But network still not working after a reboot with the original Pi also on the same LAN.
Funny though, I can ping to it but not ssh.
Ethernet just not getting set up properly.
I believe this post contains the answer. The pi will respond to a ping so the ethernet connection is correct.

The ssh does not work so I suspect this is the problem. What error message do you receive when you attempt to initiate a SSH session?

Butch
Did you regenerate the user's ssh keys on the cloned system?
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

patfenton
Posts: 11
Joined: Thu May 13, 2021 8:51 am
Location: Dublin

Re: Cloned PIs won't work on same LAN

Sat May 15, 2021 2:17 pm

jj_0 wrote:
Fri May 14, 2021 2:52 pm
What happens if you swap the SD-cards of both Pi's is it then the other Pi that has the issue?
I haven't done that as the original Pi (the one that I cloned from) is in production and working as a real system. I'm just a bit worried that I will end up breaking the production system. My plan is to buy a third Pi and I will then be able to work on it offline from the main network.

bls
Posts: 1485
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA

Re: Cloned PIs won't work on same LAN

Sat May 15, 2021 3:40 pm

I did some testing on my network, which of course is different from yours, but the tests I ran worked correctly. I used DHCP-assigned addresses so that I could see any errors from my Pi-based DHCP server, and I used Pi4s, which were handy.

Observations:
  • The cloned Pi tried to get the original IP address. My DHCP server (which uses MAC-assigned static addresses) declined that, so the cloned Pi asked for another address and got the MAC-assigned IP address. All good there
  • The second Pi to boot had an avahi name conflict because I didn't change the computer name. But, everything worked correctly
In re-reading this thread, I note that there isn't a single bit of technical information on what "The second Pi works perfectly on a different network but will not work on the same network as the first Pi." means.

@epoch1970 suggested looking at the logs, but no response from OP to this suggestion.

Resolving issues like this requires a better understanding of the problem. OP, it would be VERY helpful if you could post logs (in code tags) from the second (failing) Pi showing how it doesn't work on the same network as the first Pi. I'm guessing it's something to do with avahi, but we're all guessing since we haven't seen the actual error yet.
Pi tools:
Quickly and easily build customized-just-for-you SSDs/SD Cards: https://github.com/gitbls/sdm
Easily run and manage your network's DHCP/DNS servers on a Pi: https://github.com/gitbls/ndm
Easy and secure strongSwan VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

LTolledo
Posts: 5376
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: Cloned PIs won't work on same LAN

Sat May 15, 2021 7:07 pm

probably the second Pi's IP address is conflicting with another device in the network?

this is the reason why setting static IP on the device is not recommended
instead, setting the router to reserve IP address for the devices connected...
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

bls
Posts: 1485
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA

Re: Cloned PIs won't work on same LAN

Sat May 15, 2021 7:08 pm

LTolledo wrote:
Sat May 15, 2021 7:07 pm
probably the second Pi's IP address is conflicting with another device in the network?

this is the reason why setting static IP on the device is not recommended
instead, setting the router to reserve IP address for the devices connected...
That's one of several possibilities. However, only the actual logs from the problematic device will say for sure. :roll:
Pi tools:
Quickly and easily build customized-just-for-you SSDs/SD Cards: https://github.com/gitbls/sdm
Easily run and manage your network's DHCP/DNS servers on a Pi: https://github.com/gitbls/ndm
Easy and secure strongSwan VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

patfenton
Posts: 11
Joined: Thu May 13, 2021 8:51 am
Location: Dublin

Re: Cloned PIs won't work on same LAN

Sun May 16, 2021 12:37 pm

All is working now and thanks to everyone for contributing.
Turns out I have a dodgy Powerline adapter that I was using to connect to the router. I noticed that it was flashing very excessively so I moved my test rig to beside the router. When doing my tests to set up a local network, I had been taking the Powerline adapter out of circuit. I never suspected it because I was getting a ping back at least on some occasions.
But that left me scratching my head as to why ping worked at least sometimes. So I did some digging and it turns out a printer being used by someone working from home was being turned on and off and camping on my static IP. I had checked the IP was free before I started testing and probably the printer was off or camped elsewhere at that stage.
So a combination of a hardware fault and my stupidity just wasted a lot of your time and I apologise for that.
But I have learned that I need to setup DHCP on the router to reserve some static IP addresses.
So my next task is to start again from scratch and reclone the original then just change the hostname and IP address and see if that is sufficient to get it working and take it from there. I will post the result here.
Thanks again to everyone.

patfenton
Posts: 11
Joined: Thu May 13, 2021 8:51 am
Location: Dublin

Re: Cloned PIs won't work on same LAN

Mon May 17, 2021 4:28 pm

It is easy to clone the RPi and use the cloned Pi on the same network, provided you follow some simple steps and don’t make silly mistakes like I did. I have two RPi 3 Model B +. I have one in production but want to be able to use the backup unit for test and development but have it available to press into production if the production unit dies. Also, I don’t want to go to the trouble of installing all the modules again on the backup.
I cloned the backup RPi from the original RPi using the SD Copier software that comes with Raspbian and a USB to SD Card Reader.
When the copying is complete eject the cloned SD card
sudo eject /dev/sda # Make sure /dev/sda is the name of the cloned SD card.
If you want to keep a copy of the image on your Windows or Linux system plug the USB to SD Card Reader into your PC
For Windows, use Win32DiskImager to take a full image of the original for safe keeping.
Put the SD Card into the backup RPi and boot without the network connected. Modify /etc/dhcpcd.conf to include, using your own subnets.
interface eth0
static ip_address=192.168.0.xxx/24 # Use your own IP address
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

If you use a static IP address make sure that it is outside the range of addresses available on your router to be allocated by DHCP.
If you are using Raspbian LXDE you can modify the hostname and password from the GUI with Preferences/ Raspberry Pi Configuration. It is better to change the hostname and password on the cloned Pi although this may not be absolutely necessary, (I didn’t check).
Shutdown, connect the network, repower, and it should work. Nothing else required. If you have apps that autostart you may wish to remove them. And if you have apache or another webserver installed, you may want to stop it on the cloned Pi.
The cloned RPi is now available for use as a test and development computer. If the original RPi goes faulty just use Win32DiskImager to copy the saved image back to the SD card and without any other changes replace the faulty unit with the backup RPi and you are back in business.

Return to “Networking and servers”