1

I have used dhcpd on my Raspberry Pi with Stretch Lite installed to configure my static IP, however this will only work on the private robot network. When testing and developing, I connect it to my home network to SSH into it.

How can I set a static IP for one network, but use a dynamic one on all other networks? Both are connected with the eth0 interface.

Josh
  • 11
  • 1

1 Answers1

1

Fallback profile

It is possible to configure a static profile within dhcpcd and fall back to it when DHCP lease fails. This is useful particularly for headless machines, where the static profile can be used as "recovery" profile to ensure that it is always possible to connect to the machine. The static profile is setup as any other Static IP Address

# define static profile
profile static_eth0
static ip_address=⋯
static routers=⋯
static domain_name_servers=⋯

# fallback to static profile on eth0
interface eth0
fallback static_eth0

See How to set up networking/WiFi

Milliways
  • 54,718
  • 26
  • 92
  • 182