1

Say wifi1 is on 192.168.1.1 and wifi2 is on 10.11.11.1, I think I need a separate static IP for each network e.g. 192.168.1.233 won’t work on wifi2. Is there a way the raspberry pi can automatically switches between IP’s based on which WiFi it's connected to?

IAUSHYJ
  • 13
  • 2

2 Answers2

1

dhcpcd can configure interfaces dependent on the host network. This uses the Address Resolution Protocol (ARP) to probe hosts based on MAC or IP address before attempting DHCP resolution.

See Host Specific Configuration in How to set up networking/WiFi

Milliways
  • 59,890
  • 31
  • 101
  • 209
0

go to dhcpcd.conf and edit IP address as per each wifi requirement and enable ARPing.

Try this way:

interface eth0
arping 192.168.2.1
arping 192.168.4.50
profile 192.168.2.1
static ip_address =192.168.2.44/24
static routers=192.168.2.1
static domain_name_servers=192.168.2.1

profile 192.168.4.50
static ip_address=192.168.0.44/24
static routers=192.168.4.50
static domain_name_servers=192.168.4.50

Refer https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=140252

Dipti
  • 36
  • 5
  • 3
    It would be helpful if you would give more details on how exactly this should / could be done. – Dirk Feb 07 '19 at 11:27