Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Collapse
Brand Logo

ModalAI Forum

  1. ModalAI Support Forum
  2. Ask your questions right here!
  3. Robust way of setting static IP

Robust way of setting static IP

Scheduled Pinned Locked Moved Ask your questions right here!
2 Posts 2 Posters 293 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jon
    Regular
    wrote on last edited by
    #1

    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.

    Alex KushleyevA 1 Reply Last reply
    0
    • J jon

      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.

      Alex KushleyevA Offline
      Alex KushleyevA Offline
      Alex Kushleyev
      ModalAI Team
      wrote on last edited by Alex Kushleyev
      #2

      @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

      1 Reply Last reply
      0

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      ModalAI
      Categories Recent Tags ModalAI.com Docs
      © 2026 ModalAI® · Accelerating autonomy for smaller, smarter, safer drones · Powered by NodeBB
      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups