1

I need the following action in my Raspberry Pi 3. When the pi boot, it will try to use static IP (which already configured) on an Ethernet interface. If it fails, then it will get an IP from the DHCP server. I came across with the dhcpcd fallback profile however it seems it does the opposite of my requirement. Is it possible to configure fallback profile to first try to static IP and if it fails, try DHCP server?

Or if there is any other methods, I can take a look.

3
  • 2
    Unless you set it incorrectly setting a static IP address can NEVER "fail"
    – Milliways
    Commented May 9, 2018 at 10:02
  • Hmm, what will happen if the IP duplication case? There will be multiple pi devices and the static ip addresses may change during time. Is there a way to detect ip duplication?
    – Black Glix
    Commented May 9, 2018 at 10:50
  • From your host? You might be able (with a sniffer) to see arp requests asking for the mac address of your IP address and you might see arp responses saying that it's associated to a different MAC from your network interface... can you do it at the "application" level? I'm not sure. Perhaps you could write something that can make an ARP request asking for who is associated to the IP you want to assign to your interface and see if someone responds... but even if you assign it if no one answers, a DHCP server (if it's been used) won't take notice of your assignment so it might break later on.
    – eftshift0
    Commented May 9, 2018 at 14:12

1 Answer 1

2

There is no way to do what you want. Either you set static ip addresses. Then you are responsible that there are no duplicate ip addresses on your network which will confuse communication. That's by definition. Or you let it do appropriate software like a dhcp server or avahi / bonjour / zeroconf. Of course you can mix it up but with static ip addresses you are always responsible that it isn't double and not given by software. So I suggest let only software do its work and everything is good.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.