Article 54A0Q Alternating between DHCP and a static address depending on availability

Alternating between DHCP and a static address depending on availability

by
Turbocapitalist
from LinuxQuestions.org on (#54A0Q)
I've got a system which is afflicted with dhcpcd and would like to find a way to configure it so that it uses DHCP to fetch an address automatically when DHCP is available but falls back to a static address when there is no network. How can I do that with dhcpcd? Or is that not possible and I must find another way using /etc/interfaces/ or something?

What I've tried has been to append the following to /etc/dhcpcd.conf:

Code:# define static profile
profile static_wlan0
static ip_address=192.168.1.12/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1

# fallback to static profile on wlan0
interface wlan0
fallback static_wlan0That gives me an IPv4 address when there is networking and a DHCP server available. But when there is no netwokring, there is no IPv4 address either. I would have expected the wlan0 interface to get assigned the IPv4 address 192.168.1.12 during the network outages.

I've done a lot of searching and the web pages found mostly write about using a static address only. The others show a similar approach to the above attempts. Something is missing or misunderstood.

How do I get the interface to keep its IPv4 address regardless of whether there is an external network available or not?latest?d=yIl2AUoC8zA latest?i=wdZYjyX2oTA:6RR1tG4PDvY:F7zBnMy latest?i=wdZYjyX2oTA:6RR1tG4PDvY:V_sGLiP latest?d=qj6IDK7rITs latest?i=wdZYjyX2oTA:6RR1tG4PDvY:gIN9vFwwdZYjyX2oTA
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments