Closed benfrancis closed 1 week ago
@ogra1 The way I have been planning to implement this is to request the network-manager
interface and configure networking by communicating with NetworkManager over D-Bus from Node.js. I previously did something similar for Krellian Kiosk, but it's quite low level and fiddly to implement and I found the documentation of the NetworkManager D-Bus API quite difficult to understand.
I note that there appear to be multiple interfaces for modifying network settings so before I make a start on this, is there a simpler approach I should be considering?
The WebThings Gateway user manual should give you an idea of the kinds of settings which need to be modified from Node.js.
There are other settings that will need implementing later including configuring mDNS, and a Wi-Fi hotspot during first time setup.
Potential approaches to implementing networking on Ubuntu Core:
ip netns
, providing a wide, privileged access to networking" - I don't know a lot about this
- network-manager interface "enables access to NetworkManager, providing privileged access to configure and observe networking." - Does this just mean via DBus, or also the nmcli command line interface?
- dbus npm module to provide raw access to dbus
FYI I've made a start using this approach in https://github.com/WebThingsIO/gateway/pull/3168 so we'll see how it goes.
"enables access to NetworkManager, providing privileged access to configure and observe networking." - Does this just mean via DBus, or also the nmcli command line interface?
If you include nmcli
in the snap, you should be able to use it. You can see what the network-manager snap does to accomplish its tasks in this matter.
@dilyn-corner wrote:
If you include nmcli in the snap, you should be able to use it. You can see what the network-manager snap does to accomplish its tasks in this matter.
Hah, it would have been useful to know that ~1,000 lines of code ago! But by the looks of it that requires building nmcli from source inside my snap, which seems a bit excessive. And my assumption was that the DBus API would be more stable than the command line interface. So possibly simpler from the application code point of view, but definitely more complicated from a multi-architecture build point of view.
Having spent a large proportion of the last few weeks implementing network settings for the gateway using the DBus API (which is now nearly finished) I guess I'm kind of committed to that route now, so I'll have to see how it goes.
😅 I do agree that the dbus API is probably more stable and it is usually the way I'd recommend going.
@dilyn-corner / @ogra1 I'm seeing something odd I can't explain.
I'm setting a static IP address (and subnet and gateway) via the NetworkManager D-Bus API on Ubuntu Desktop, using org.freedesktop.NetworkManager.Settings.Connection.Update()
. It appears to save the settings successfully and when I view network settings in the Ubuntu Settings UI or with nmcli
it shows the new settings. However, if I then check my current IP address using ip a
or hostname -I
I see the old IP address.
What am I missing?
Huh, it appears that Update()
does not actually update the settings, you have to call Reapply()
on the Device object or re-active the connection in order for the changes to take effect...
As a user I want to be able to configure my network settings when using the snap package so that I can connect my gateway to a network.
Currently clicking on Network Settings in the web interface when using the snap package on Ubuntu displays a message which says "Network settings are not supported for this platform." This is because network settings are not implemented for Ubuntu, or Ubuntu Core.
This will require implementing network settings using NetworkManager in linux-ubuntu.ts and/or creating a linux-ubuntu-core.ts in /src/platforms.
See https://github.com/krellian/kiosk/blob/master/services/models/network.js for inspiration.
This will likely also require the snap to be permitted to use an additional interface.