1

In order to clarify my question -

cat /proc/device-tree/model:

Raspberry Pi 3 Model B Rev 1.2

cat /etc/os-release:

PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
NAME="Raspbian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
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"

apache2 -v:

Server version: Apache/2.4.51 (Raspbian)
Server built:   2021-10-07T17:49:44

mysql -V:

mysql  Ver 15.1 Distrib 10.5.12-MariaDB, for debian-linux-gnueabihf (armv7l) using  EditLine wrapper

ip r | grep default:

default via 192.168.1.254 dev wlan0 proto dhcp src 192.168.1.76 metric 303

sudo nano /etc/resolv.conf:

# Generated by resolvconf
nameserver 192.168.1.254

I hope I have generated the necessary information you need to assist me. I am new to this, so I looked-up those commands. I have two SD cards, but only one Raspberry Pi 3. Above is what I have installed on one SD card. The issue I'm having is I have another SD card that I plan on using - installing the same above, but when I go to install everything - then the IP address is still the same:

192.168.1.76

I am wanting the second SD card to be something like:

192.168.1.46

So, when I swap out the SD cards, then the local IP address is already changed. Is this even possible?

Thank you for your time.

EDIT:

ip a && ip r:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
   valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
   valid_lft forever preferred_lft forever
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether b8:27:eb:82:72:4d brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:d7:27:18 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.76/24 brd 192.168.1.255 scope global dynamic noprefixroute wlan0
       valid_lft 56330sec preferred_lft 45530sec
    inet6 2600:1700:3b01:2a70:b648:20cf:994:626/64 scope global dynamic mngtmpaddr noprefixroute
       valid_lft 3208sec preferred_lft 3208sec
    inet6 fe80::cdc9:5bc:9b4e:7f4b/64 scope link
       valid_lft forever preferred_lft forever
default via 192.168.1.254 dev wlan0 proto dhcp src 192.168.1.76 metric 303
192.168.1.0/24 dev wlan0 proto dhcp scope link src 192.168.1.76 metric 303
Sanders
  • 83
  • 7

2 Answers2

1

What you want is possible and quite simple.

Include the following in /etc/dhcpcd.conf

interface wlan0
request 192.168.1.76

See Setup a Static IP Address in How to set up networking/WiFi for detail.

(Most Pi users go to some lengths to ensure that each Pi has a unique address, so this is unusual and I wonder WHY?)

NOTE you will get suggestions to use a Static IP Address; this is commonly (and inappropriately) suggested on the Pi, but the simple rule is if you have a router on your network do not set a Static IP Address.

Milliways
  • 54,718
  • 26
  • 92
  • 182
  • Thank you so much for the guidance. I updated my original post with the `ip a && ip r`. I wasn't clear - I'm not necessary wanting a unique address for each card. I'm just wanting to make sure they're different local addresses regardless what the router assigns.. Maybe I'm doing all of this incorrect - I have two websites as a hobby, and I want each SD card to have to have its own website data. – Sanders Dec 23 '21 at 00:34
  • 1
    @Sanders as you have only 1 Pi I fail to see the need for different IP, the site data will be stored on the SD Card, but there is no problem if you want to do this. – Milliways Dec 23 '21 at 01:04
  • That's exactly what I needed to know. I misunderstood what I had been reading elsewhere - that this would somehow produce a conflict. – Sanders Dec 23 '21 at 01:30
1

Typically the IP address is assigned from a DHCP server. The DHCP server looks at your hardware's ethernet address (listed after link/ether in ip addr output and gives each one a (temporary) unique IP address.

Each Pi and each network interface should have unique ethernet addresses assigned by the manufacturer.

So it is OK for different SD cards to get the same IP, because by default the IP is associated with the Pi hardware, not the SD card.

On the other hand, if you need to externally determine which SD card was booted, it might make sense to force the IP address to be associated with the SD card rather than the Pi hardware. But this would be a special case.

user10489
  • 794
  • 1
  • 3
  • 9
  • Yeah, the hardware ethernet address is more commonly referred to as the MAC [Media Access Control](https://en.wikipedia.org/wiki/MAC_address) address and is ***usually*** a unique number "burnt-in" to the network interface hardware - and it relates to that interface rather than the "computer" that has that hardware - which is an important point to note if the computer has more than one connection to one/more network(s)! – SlySven Dec 25 '21 at 19:28