0

I have a switch on my PI and I want to be able to use a static ip or dynamic ip based on the switches position.

Is it possible to get GPIO pin data in dhcpcd.conf?

3
  • 1
    you're dealing with linux, anything is possible
    – jsotola
    Commented Aug 13, 2020 at 2:44
  • As jsotola said anything is possible but if you explain what you want to achieve you may get a more helpful suggestion.
    – Milliways
    Commented Aug 13, 2020 at 3:44
  • 1
    do some research ... figure out how to run a script when a GPIO pin changes state ... then write a script that renames dhcpcd.dynamic to dhcpcd.conf and restarts the network daemon
    – jsotola
    Commented Aug 13, 2020 at 5:28

1 Answer 1

3

The Answer to the Question you actually asked is quite simple.

dhcpcd is a generic service which is applicable to ANY Linux distribution.
It is NOT specific to the Pi, has no knowledge of the Pi hardware, and thus has NO code which could interrogate the Pi hardware.

It would be possible to write some code to re-configure dhcpcd when a GPIO pin changes state, but you will have to write this yourself.

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.