I have a notebook that has both a Wired (enxa0cec80070b7
) and a WiFi adapter (wlp1s0
)
I use my router’s reserved address feature to assign a DHCP address to each device
172.16.68.13: wlp1s0
172.16.68.14: enxa0cec80070b7
This machine will be moved back and forth to a different network (and others) that will have 172.16.71.1 as its gateway.
In /etc/bash.bashrc
I have this snippet which will set an environment variable called SERVER_IP
which is used by various services.
IP="$(ip addr show enxa0cec80070b7 | awk '$1 == "inet" { print $2 }' | cut -d/ -f1)"
export SERVER_IP=${IP}
Assume I use the router to always assign .13 and .14, regardless of what network the machine is on.
I would always like to be able to use the .14 IP address, even if it’s not connected —- and if it’s not to use the .13 as backup, which should always be connected.
Is this possible?