Voxl 2 Mini Static IP
-
@bendraper It is possible to set a static ip on both the voxl2 and voxl2 mini.
It is just ubuntu OS. What modem/router are you connecting to?
-
@wilkinsaf I was just connecting to my laptop for now. Laptop set with a static IP
-
Here is what one of my guys uses
ip addr flush dev eth0 ip link set dev eth0 up ip addr add 192.168.1.100/255.255.255.0 dev eth0
-
i would make sure that the ethernet is the only thing connected that is supplying network connectivity. (no modem, 4g/5g hat, etc...)
otherwise you willl need to do some extra configuration with voxl-modem -
@wilkinsaf This worked! Thank you
-
@wilkinsaf Actually it seems these settings don't stick after rebooting the voxl... Any ideas?
-
@wilkinsaf google seems to suggest changing a /etc/network/interfaces file may do the trick but this file does not exist in the voxl filesystem
-
If you make a script to do this, you might want to make it monitor eth0 state so if eth0 goes down and back up, the IP doesn't get removed.
Here's a bash example of what I do to check the IP address of ethernet and put it back if it goes down and back upwhile 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/255.255.255.0 dev $eth_dongle_interface fi sleep 1 done
Of course, this is in my modified voxl-modem with custom variables for the interface (eth0 or eth1) and variables for the IP address. You might just want to hard code those when testing.
-
@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. -
After having some issues with a static IP on the VOXL2 Mini above it ended up being an issue with being on the wrong subnet for the host computer to communicate.
We ended up fixing the issue by changing the subnet for the host computer once we changed the IP on the VOXL2 Mini.
e.g VOXL2 Mini IP of 192.168.144.15 will require a host computer on the same subnet e.g. 192.168.144.98.