Create new wired network file

I need to make a wired network connection config file similar to the “resin-wifi” that you can statically assign an ip in. I was going to copy the “resin-sample.ignore” file and rename the copy to “resin-connection” or something like that. I don’t know how to copy the files using the terminal interface under the balena dashboard that good. I thought when you have a wired connection plugged in upon boot that it automatically created a config file for that, but I maybe mistaken with that. I need help with crating a file for me to statically assign the ethernet connection an ip along with other mods for the connection. Thanks in advance

I hope this comprehensive description assists you in what you’re looking to do. Let us know if there’s anything you would like clarified!

What is the connection file?

You want to create a .conf file in /etc/NetworkManager/system-connections, which is how NetworkManager defines the connections it manages.

But, if you edit the file in there on a live device, you should be careful, as that will be cleared on reboot.

Using nmcli to generate a static ethernet config

You really should generate a config and include it in the OS image before using etcher to burn to the SD

You can generate the connection file on the running system using the nmcli command-line tool. You can read about nmcli documentation in the nmcli man page or online.

Example nmcli generation of config

A command which would create a static ip ethernet connection (ip on eth0 with the gateway/dns being at is:

nmcli connection add \
    save yes \
    type ethernet \
    ip4 \
    gw4 \
    ipv4.dns, \
    ifname eth0

If you then check /etc/NetworkManager/system-connections to see what was created, you can put that file into the .img file, unmount it, and re-run etcher. That OS image will now have the connection profile persisted across reboots.

To mount the image file, run this command (mounts to /mnt/sd0, and uses an example .img filename):

sudo mount -o rw,loop,offset=$((8192 * 512)) balena-cloud-your-appname-raspberry-pi-2.32.0+rev1-dev-v9.14.0.img /mnt/sd0

An example config

The file you generate may end up looking something like this:





A final note: This generates a static ipv4 config, ipv6 is still on auto.

Thank you, that worked. :+1: