Trying to set up static ip on raspberry zero w. Using the following code
#!/bin/sh
interface="wlan0"
ssid="xxxxxx"
pass="xxxxxx"
ipaddr="192.168.1.249"
netmask="255.255.255.0"
gateway="192.168.1.1"
dns1="192.168.1.251"
dns2="8.8.8.8"
wpa_passphrase ${ssid} ${pass} > /etc/wpa_supplicant.conf
wpa_supplicant -i ${interface} -c /etc/wpa_supplicant.conf -B >/dev/null 2>&1
ifconfig ${interface} ${ipaddr} netmask ${netmask} up
route add default gw ${gateway}
echo nameserver ${dns1} >> /etc/resolv.conf
echo nameserver ${dns2} >> /etc/resolv.conf
This will boot to prompt and set up the static ip consistently with a keyboard dongle plugged in. Unplug the keyboard and reboot, no static ip until a keyboard is plugged in.
This is for a wifi camera using mjpeg-streamer. Works great until I try to setup a static ip. The satellite modem we're using here in the middle of a desert can reset during a thunderstorm and change addresses of local devices. Of course, this necessitates a rescan to determine which is now the camera server.
How to boot to server completely headless using static ip? Motioneyeos and motion are not options as they perform poorly.