I initially experienced a few issues with VLANs and ended up having to nuke the device and perform a fresh install. Everything is now working and I've backed up my settings.
I have configured a 5GHz Wi-Fi access point as a fail safe to ensure I can always gain access to the device. I'd rather not leave this running all the time because the RP4 is sat next to my wireless access point and might cause interference/degradation of my main Wi-Fi.
Is it possible to have the Wi-Fi come on for say 30 minutes when the device first boots and then automatically turn off? That would allow me enough time to boot the device, log in via Wi-Fi and make the necessary changes to get the device back online.
You can do this in /etc/rc.local... just something like
wifi on
sleep $((30*60))
wifi off
You might need to put those commands in their own script file and then run that script in the background... I'm not sure what happens if rc.local itself runs for 30 mins
Set switch port that rpi-lan connects to... to accept (!ALSO! not 'JUST") (tagged VLAN90)... give the switch an ip in this management range ( i.e. 10.90.90.2 )
Set additional optional switch ports (not wan if possible) to also tag (or not tag = management port) VLAN90
you could then tag or not tag VLAN90 on certain switch interfaces you want management access... or route straight through ( or firewall block ) when the router is functioning correctly...
The problem was that the Raspberry Pi wasn't routing between VLANs and I wasn't able to access the router. That's now sorted, but it was a real pain getting locked out and, due to the single interface, it wasn't possible to get back in again.
with the above config... you can assign VLAN90 tagging to your laptop (and a static ip because we have not setup dhcp on the management vlan) ( or plug it into a 90-untagged~access/management port ) and still have access in most cases...
these are parts of how i'm doing it... may be of use (although had to strip some stuff out so... you may need to make some effort to have it work properly)
#!/bin/sh
MODEL="4-model-b"
ecmd="echo ${i} "
writewatcher() {
cat <<'EOF' > /bin/wifiwatcher.sh
#!/bin/sh
i=wifiboot
ecmd="echo ${i} "
radio="$1"; WDURATION="$2"; SNAME="wifiwatcher.sh"
LOGFILE="/tmp/wifiwatcher.sh.log"
if [ "$(uci -q get wireless.default_$radio.disabled)" -eq 1 ] || [ "$(uci -q get wireless.$radio.disabled)" -eq 1 ]; then
$ecmd "state is disabled"
else
$ecmd "state is not disabled [exit]"; exit 0
fi
if [ -f "/tmp/.wifiadminwatch.sh.on" ]; then
echo "Already running: /tmp/.wifiadminwatch.sh.on" >> $LOGFILE
$ecmd "Already running: /tmp/.wifiadminwatch.sh.on"
exit 0
fi; touch /tmp/.wifiadminwatch.sh.on
echo "$radio enable" >> $LOGFILE
uci -q set wireless.$radio.disabled='0'
uci -q set wireless.default_$radio.disabled='0'
wifi down; sleep 2
/etc/init.d/wpad restart; sleep 2
wifi up; sleep 2
$ecmd "AdminWifiBoot [on:$WDURATION]"
while [ "${WDURATION}" -gt 0 ]; do
if [ "$WDURATION" -eq 30 ]; then
iw dev wlan0 station dump | grep -oE '[[:xdigit:]]{2}(:[[:xdigit:]]{2}){5}'
$ecmd "[30seconds-remain]"
fi
if [ "$WDURATION" -eq 60 ]; then
iw dev wlan0 station dump | grep -oE '[[:xdigit:]]{2}(:[[:xdigit:]]{2}){5}'
$ecmd "[1minutes-remain]"
fi
if [ "$WDURATION" -eq 120 ]; then
iw dev wlan0 station dump | grep -oE '[[:xdigit:]]{2}(:[[:xdigit:]]{2}){5}'
$ecmd "[2minutes-remain]"
fi
sleep 1; WDURATION=$((${WDURATION} - 1))
echo $WDURATION > /tmp/.wifiadminwatch.sh.on
done; $ecmd "AdminWifiBoot [off]" #logger -t $SNAME "time-up"
rm /tmp/.wifiadminwatch.sh.on
#stop wireless here
EOF
chmod +x /bin/wifiwatcher.sh
}
getradioinfo() {
radio="$1"
if uci -q get wireless."$radio" 1>/dev/null; then
$ecmd "######################## Checking radio: $radio"
ssid="$(uci -q get wireless.default_${radio}.ssid)"
key="$(uci -q get wireless.default_${radio}.key)"
encryption="$(uci -q get wireless.default_${radio}.encryption)"
channel=$(uci -q get wireless."$radio".channel)
htmode=$(uci -q get wireless."$radio".htmode)
hwmode=$(uci -q get wireless."$radio".hwmode)
disabled=$(uci -q get wireless."$radio".disabled)
country=$(uci -q get wireless."$radio".country)
wifiisdisabled=$(uci -q set wireless.radio0.disabled)
else
$ecmd "Checking radio: $radio [not-found]" && return 1
fi
return 0
}
for thisradio in ${allradios}; do
if getradioinfo "$thisradio"; then
if [ ! -z "$wifiisdisabled" ] && [ "$wifiisdisabled" -ne 1 ]; then
$ecmd "$radio is already enabled"; continue
elif [ "$ssid" = "OpenWrt" ]; then
$ecmd "$radio defaultssid: $ssid [x]"
else
toggleradio=1
fi
fi
if [ ! -z "$toggleradio" ]; then
$ecmd " WIFIADMINBOOT: $WIFIADMINBOOT WIFIADMINBOOTTIME $WIFIADMINBOOTTIME"
writewatcher
sh /bin/wifiwatcher.sh "$radio" "${WIFIADMINBOOTTIME:-230}" &
else
$ecmd "$radio not suitable defaultssid|nopw|alreadyon"
fi
done
exit 0
The file 'vi /etc/config/rc.local' was completely blank before I entered the code. Am I looking at the right file? Should there be other config already in there?