# Robust way of setting static IP

Source: https://forum.modalai.com/topic/4915/robust-way-of-setting-static-ip
Category: General Questions (https://forum.modalai.com/category/2/general-questions)
Posted: 2025-12-09 14:48:00 UTC by jon
Replies: 1 · Views: 402

## jon · 2025-12-09 14:48:00 UTC

Right now I'm using this bash script to set a static ip:

```
ETHERNET_IP=192.168.1.100
eth_dongle_interface=eth0

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/255.255.255.0 dev $eth_dongle_interface
    fi
    sleep 1
done
```

It's pretty reliable, but we have seen it fail and the default 169.254.4.1 address takes over the eth0 interface. I believe this the Qualcomm DHCP manager? Is there any way to edit the network manager directly? We have tried deleting it but it seems to regenerate on boot.

## Reply by Alex Kushleyev (ModalAI staff) · 2025-12-10 06:12:12 UTC

@jonathankampia ,

Here is something i tried, you can try as well. You are right, there is a background service that may be taking over, I think i found how to disable it:

```
systemctl disable QCMAP_ConnectionManagerd
systemctl disable qti_pppd
systemctl disable qtid

rm /lib/systemd/system/multi-user.target.wants/QCMAP_ConnectionManagerd.service
rm /lib/systemd/system/multi-user.target.wants/qti_pppd.service
rm /lib/systemd/system/multi-user.target.wants/qtid.service

#edit: instead of disabling the above 3 services and removing the entries from `multi-user.target.wants`, it seems you can do the following:
systemctl mask QCMAP_ConnectionManagerd
systemctl mask qti_pppd
systemctl mask qtid

# you may want to disable dhcpcd as well, but i dont think that is strictly necessary:
systemctl disable dhcpcd
```

Now, set up static connection:

```
#create a new network interface file
vi /etc/systemd/network/10-eth0.network
```

```
[Match]
Name=eth0

[Network]
Address=192.168.xx.xx/24
Gateway=192.168.xx.1
DNS=8.8.8.8 1.1.1.1
```

enable networkd
```
systemctl enable systemd-networkd
```

Then reboot voxl2...

I think if `dhcpcd` is enabled, it may first take over the interface, but then networkd takes it back.. For example, here is the log from `networkd` when `dhcpcd` is enabled:
```
...
Dec 10 06:01:00 m0054 systemd-networkd[1126]: dummy0: Gained carrier
Dec 10 06:01:00 m0054 systemd-networkd[1126]: dummy0: Gained IPv6LL
Dec 10 06:01:11 m0054 systemd-networkd[1126]: eth0: Gained carrier
Dec 10 06:02:13 m0054 systemd-networkd[1126]: eth0: Gained IPv6LL
Dec 10 06:02:13 m0054 systemd-networkd[1126]: eth0: Configured
Dec 10 06:02:13 m0054 systemd-networkd[1126]: docker0: Link UP
Dec 10 06:02:21 m0054 systemd-networkd[1126]: eth0: Lost carrier
Dec 10 06:02:36 m0054 systemd-networkd[1126]: eth0: Gained carrier
Dec 10 06:02:38 m0054 systemd-networkd[1126]: eth0: Gained IPv6LL
Dec 10 06:02:38 m0054 systemd-networkd[1126]: eth0: Configured
```

and the log with dhcpcd disabled:
```
...
Dec 10 06:02:13 m0054 systemd-networkd[1126]: bond0: Link is not managed by us
Dec 10 06:02:13 m0054 systemd-networkd[1126]: sit0: Link is not managed by us
Dec 10 06:02:14 m0054 systemd-networkd[1126]: eth0: Link UP
Dec 10 06:02:38 m0054 systemd-networkd[1126]: eth0: Gained carrier
Dec 10 06:09:56 m0054 systemd-networkd[1126]: eth0: Gained IPv6LL
Dec 10 06:09:56 m0054 systemd-networkd[1126]: eth0: Configured
Dec 10 06:09:56 m0054 systemd-networkd[1126]: docker0: Link UP
```

Can you try and see if that solves your issue?

Alex
