Setting a Static IP for Ethernet

Hi,

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.

Thanks

Hi Gregor, welcome to the forums!

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):

[ipv4]
address1=192.168.1.111/24,192.168.1.1
dns=8.8.8.8;8.8.4.4;
dns-search=
method=manual

You can read more about networking in balenaOS and particularly setting a static IP for Ethernet in our documentation here:

Hi Tmigone,

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.

You can create a new file an name it however you like, I suggest you use resin-ethernet or something like that to make it evident.

You can use the contents of the sample file to know what they should be, or copy them from the documentation:

[connection]
id=my-ethernet
type=ethernet
interface-name=eth0
permissions=
secondaries=

[ethernet]
mac-address-blacklist=

[ipv4]
address1=192.168.1.111/24,192.168.1.1
dns=8.8.8.8;8.8.4.4;
dns-search=
method=manual

[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=auto

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).

Thanks for your reply,

So if my router’s admin panel is 192.168.1.254 and I wanted my devices IP to be 192.168.1.100 would my line be:

address1=192.168.1.100/192.168.1.254

Is this correct?

Not exactly you would want it to be:

address1=192.168.1.254/24,192.168.1.100

The /24 indicates the subnet mask you want to use (in this case /24 --> 255.255.255.0) which is also required when setting an address.

Is the routers IP address the same as the IP used to reach its admin panel?

Yes it should be unless you have a super custom setup, but it’s extremely unlikely.

Hi tmigone I added the file to the device but it is not coming back online. The green light on the pi is flashing repeatedly in groups of 4 flashes.

Okay, that would indicate that we messed up the connection file. LED flashing pattern means no connection:

Can you paste the contents of the file in here?

Thanks for the reply, the file is called resin-ethernet and the contents of the file are:

[connection]
id=my-ethernet
type=ethernet
interface-name=eth0
permissions=
secondaries=

[ethernet]
mac-address-blacklist=

[ipv4]
address1=192.168.1.254/24,192.168.1.100
dns=8.8.8.8;8.8.4.4;
dns-search=
method=manual

[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=auto

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:

[ipv4]
address1=192.168.1.100/24,192.168.1.254

Thanks!

Should the connections file have a filetype?

I Think that worked! Thanks for all your help!

Excellent! Sorry we got that mixed up the first time.

:slight_smile: