I’m trying to set a static IP address for my Raspberry Pi 3B+ running Pi-Hole. The device is set up to only use an Ethernet connection and I’m struggling to find the connections file to change the devices IP.
Can anyone help?
I’ve read through some of the other topics on the forums but I can’t quite work out what to do.
You can configure a static IP address for your balena device by editing the files inside system-connections directory if you mount your SD card on your computer.
You would need to add the following snippet (tuned to your liking of course):
I’ve mounted the SD card in my computer but the only files in the system-connections directory are README.ignore and resin-sample.ignore.
Where should I add this snippet?
Do I need to create a new file?
I think I read that documentation but I couldn’t work out where to set the information as I had only ever edited the resin-wifi-01 file which doesn’t exist in this device.
Remember for the address1=192.168.1.111/24,192.168.1.1 line you should put both the desired static IP and the gateway (your routers IP address most likely).
Hi Gregor, taking a second look at this file, it seems that the local IP Address and Gateway Address are actually backwards in the file, sorry about that! Give this a try instead:
Hi @tmigone I have down this successfully earlier however last week my Pi SD card gone bad and I am adding a new device. I get following error file nmcli reload -
May 09 01:00:59 dfc7315 NetworkManager[1614]: [1652058059.9498] keyfile: ipv4.addresses: unexpected character ’ ’ for address1: '192.168.1.111/24,192.168.1.254 ’ (position 13)
May 09 01:00:59 dfc7315 NetworkManager[1614]: [1652058059.9499] keyfile: ipv4.dns: ignoring invalid DNS server IPv4 address ’ ’
May 09 01:00:59 dfc7315 NetworkManager[1614]: [1652058059.9502] keyfile: load: “/etc/NetworkManager/system-connections/resin-ethernet”: failed to load connection: invalid connection: connection.type: connection type 'ethernet ’ is not valid
Anyone seen this before, any advice on how to shoot?
Workaround update - I could not get the profile load from resin-ethernet file so hardcoded the static IP address via nmcli -
nmcli con add type ethernet con-name my-ethernet ifname eth0 ip4 192.168.1.111/24
gw4 192.168.1.254
nmcli con mod my-ethernet ipv4.dns “8.8.8.8 8.8.4.4”
i was wondering if it is possible to do this from the dashboard? we have a number of devices where we don’t fully know the IP until they are installed. so i was wondering can we do this via a variable or something and not going into the resin-* folder.
You could make a wrapper script for your actual application.
Try something like
#!/bin/bash
if [[ -n "${MY_IP_ENV_VAR}" && -n "${MY_IFACE_ENV_VAR}" ]]; then
echo "setting "${MY_IFACE_ENV_VAR}" ip: ${MY_IP_ENV_VAR}"
ip address add "${MY_IP_ENV_VAR}" dev "${MY_IFACE_ENV_VAR}"
fi
actual_command "$@"
With for example MY_IFACE_ENV_VAR=eth0 and MY_IP_ENV_VAR=192.168.1.10/24 .