@tom @wilkinsaf @Moderator I am hoping you can help shed some light on an issue with setting up the VOXL2 Mini with a static IP. I have seen mention of utilizing a customized version of voxl-modem for a static IP so perhaps I am missing something but I have tried every approach to setting a static IP and more than I have ever used with no avail. It seems there is a service that is enabled by default to clear the IP address of the VOXL2 Mini and messes with the routing of the eth0 interface because anything I implement does not function properly. I must be missing something here if you would please enlighten me
Goal:
Set a persistent static IP on VOXL2 Mini that is maintained after reboots and during operation, then access the VOXL2 Mini with an ssh connection via a Ethernet to USB adapter.
Overview of Approaches:
-Approach #1: Does NOT Work- Use commands to flush and wipe the eth0 interface and set a new IP as shown below. This works temporarily but is overwritten typically within 30 seconds while running. After a reboot, the IP address defaults back to 169.254.4.1 and VOXL2 Mini cannot be accessed via ssh on eth0.
-Approach #2: Does NOT Work- Use system.d file to set eth0 interface with a new IP as shown below. This works temporarily but is overwritten typically within 30 seconds while running. After a reboot, the IP address defaults back to 169.254.4.1 and VOXL2 Mini cannot be accessed via ssh on eth0.
-Approach #3: Does NOT Work- Use bash script to constantly check and set the IP. This works to set the IP but the VOXL2 Mini cannot be accessed via ssh on eth0.
Approach #1
Steps to Reproduce:
- adb into VOXL2 Mini
- Run:
ip addr flush dev eth0
ip link set dev eth0 up
ip addr add 192.168.1.100/255.255.255.0 dev eth0
ifconfig
- Wait 2 minutes and run:
ifconfig
Actual Result:
-IP address changes back to 169.254.4.1.
-Device no longer available via ssh on eth0 at 169.254.4.1.
Expected Result:
-IP should not change after being set.
Approach #2
Steps to Reproduce:
- adb into VOXL2 Mini
- Run:
sudo mkdir -p /etc/systemd/network
- Run:
sudo vi /etc/systemd/network/10-eth0-static.network
- Add the following to the file created above:
[Match]
Name=eth0
[Network]
Address=192.169.144.15/24
Gateway=192.169.144.1
DNS=8.8.8.8
- Run:
sudo systemctl restart systemd-networkd
sudo systemctl enable systemd-networkd
ip addr show eth0
sudo systemctl status systemd-networkd
- Wait 2 minutes and run:
ifconfig
Actual Result:
-IP address changes back to 169.254.4.1.
-Device no longer available via ssh on eth0 at 169.254.4.1.
Expected Result:
-IP should not change from 192.169.144.15 after being set.
Approach #3
Steps to Reproduce:
- adb into VOXL2 Mini
- Run:
vi /usr/local/bin/set-eth-dongle-ip.sh
- Add the following to the file created above:
#!/bin/bash
eth_dongle_interface="eth0" # Replace with your dongle interface name
ETHERNET_IP="192.168.144.15" # Replace with your desired IP address
BROADCAST_IP="192.168.144.255" # Replace with the correct broadcast address
while true; do
if [[ -e "/sys/class/net/$eth_dongle_interface" ]]; then
eth_dongle_ip=$(ip -4 addr show $eth_dongle_interface | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | head -1)
else
eth_dongle_ip=""
fi
if [[ "$eth_dongle_ip" != "$ETHERNET_IP" && -e "/sys/class/net/$eth_dongle_interface" ]]; then
echo "Setting IP address to: $ETHERNET_IP"
ip addr flush dev $eth_dongle_interface
sleep 1
ip link set dev $eth_dongle_interface up
sleep 1
ip addr add $ETHERNET_IP/24 broadcast $BROADCAST_IP dev $eth_dongle_interface
fi
sleep 1
done
- make service file executeable, run:
sudo chmod +x /usr/local/bin/set-eth-dongle-ip.sh
- create systemd service file, run:
vi etc/systemd/system/set-eth-dongle-ip.service
- Add the following to the file created above:
[Unit]
Description=Set Ethernet Dongle IP Address
After=network.target
[Service]
ExecStart=/usr/local/bin/set-eth-dongle-ip.sh
Restart=always
User=root
[Install]
WantedBy=multi-user.target
- Run:
#reload the systemd daemon to recognize the new service
sudo systemctl daemon-reload
# enable the service so that it runs on boot
sudo systemctl enable set-eth-dongle-ip.service
# start service immediately
sudo systemctl start set-eth-dongle-ip.service
# verify service has started properly
sudo systemctl status set-eth-dongle-ip.service
- Wait 2 minutes and run:
ifconfig
Actual Result:
-IP address changes back to 169.254.4.1.
-Device no longer available via ssh on eth0 at 169.254.4.1.
Expected Result:
IP should not change from 192.169.144.15 after being set.