Sharing Raspberry Pi via Ethernet port

Hi all,
I would like to use a Raspberry Pi running balena to create a local network so an iPad can talk to it using an ethernet adapter.

It’s currently working creating a wi-fi hotspot but I would like to use ethernet because it should be more reliable.
I had a look at the documentation but I can’t find an example of how to setup the network configuration files for this application
https://www.balena.io/docs/reference/OS/network/2.x/

Can you please point me in the right direction?
Any help would be appreciated,
Many thanks,
Enrico

Hi,

We already have a sample network configuration file in this section https://www.balena.io/docs/reference/OS/network/2.x/#wifi-setup, please create the file as instructed and put it in the system-connectionsdirectory

Thanks,
I already have a file in system-connections to create a wi-fi hotspot and it’s working okay.
My question is if the pi can share the same network via ethernet port as well like I router would do.

Hey @enricopenzo,

You want to connect your RPi to iPad directly through a ethernet cable?

If this is the case do you want the RPi act as a DHCP server on the wired interface and the iPad to get automatically an IP from the RPi board?

@spanceac
yes, that’s exactly what I want to achieve

There is a network manager connection profile that allows you to do this. You need to add this in resin-boot/system-connections folder from the SD card.

Will keep you updated when we find it

@spanceac
that’s great, thanks heaps for helping.
I will wait updates

@spanceac
Hello, please let me know if you have any luck finding the file,
Thanks

Hi @enricopenzo,

For DHCP server you may use dnsmasq. Here is an example dnsmasq configuration this (it will need changing the interface name to eth0) - https://github.com/balena-io-playground/hostapd-minimal/blob/master/dnsmasq.conf

The example itself is a bit old and it uses our older base images which included systemd, but you may create a container with host networking and running in privileged mode and run dnsmasq directly.

In addition to that you will need to create a NetworkManager profile assigning a static IP for the RPi as in the example here: https://www.balena.io/docs/reference/OS/network/2.x/#setting-a-static-ip

You will need to change the address1 field from the example to address1=192.168.42.1/24.

Please let me know if you have any questions or find it too confusing (I can create a small demo project if that is the case).

Thanks,
Zahari

@majorz
that’s helpful, my project already has a container with host networking running in privileged mode and with dnsmqsq installed.
I will test it and let you know if I encounter any issues, thanks

Hi @majorz,
I followed your instructions but I’m struggling a bit.

I have a multicontainer application. One container is running dnsmasq with the config file provided with interface name eth0

I added the following file in the system connection folder:
[connection]
id=my-ethernet
type=ethernet
interface-name=eth0
permissions=
secondaries=

[ethernet]
mac-address-blacklist=

[ipv4]
address1=192.168.42.1/24
dns=8.8.8.8;8.8.4.4;
dns-search=
method=manual

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

However, when I connect the pi to the ipad via ethernet port (or my mac) the ethernet interface doesn’t get the expected IP but a self assigned one like 169.254.220.255

If you can provide a demo that will greatly help!
many thanks,
Enrico

@majorz
Hello, can you please let me know if you can help?
Many thanks

Hi Enrico, sorry for the delay. Let me do some test here now and get back to you a bit later today.
Thanks,
Zahari

Hi @enricopenzo, the 169.254.x.x address that you saw is a link-local address that may fit very well a use case when you would like to connect to the RPi 3 through IPad, but it won’t provide Internet access to the RPi.

In the use case where you would like to access the Internet through the iPad and actually you do not have to run dnsmasq at all. You may delete any Ethernet NetworkManager connections with nmcli c delete and use the auto-configured default connection by NetworkManager.

Then on your iPad you need to enable Internet connection sharing - https://support.apple.com/guide/mac-help/share-internet-connection-mac-network-users-mchlp1540/mac. For “To computers using” you need to select the Ethernet connection and for “Share your connection from” you need to choose the source of the Internet (probably WiFi).

Like this the iPad will spawn a DHCP service and will assign an IP address to your RPi. Then you will be good to go.

Please let me know if that works for you.

As for link-local configuration, where you do not need Internect connection sharing, you may use the following command to create a link-local profile on the RPi:
nmcli c a ifname eth0 type ethernet ipv4.method link-local ipv6.method ignore

Then you need to activate the newly created connection profile, e.g. nmcli c up <NAME>, where you may see the name of it with nmcli c.

Then check the hostname of the RPi with hostname, e.g. it will look like ebb0e2b - a seven symbols hex number. Then you may connect to it using as a .local domain from your iPad, e.g. ping ebb0e2b.local.

And getting back to your original issue you had with the 169.254.x.x address where you run the DHCP server on the RPi side, I think it probably how Mac OS X configures it’s network. If you connect the Ethernet cable to the Mac first and wait too much, it may configure a the link-local address automatically. So it is best to first connect the cable to the RPi and then to the Mac.