Robust way of setting static IP
-
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 doneIt'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.
-
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 doneIt'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.
@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 dhcpcdNow, 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.1enable networkd
systemctl enable systemd-networkdThen reboot voxl2...
I think if
dhcpcdis enabled, it may first take over the interface, but then networkd takes it back.. For example, here is the log fromnetworkdwhendhcpcdis 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: Configuredand 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 UPCan you try and see if that solves your issue?
Alex
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