Re: Change IP address with libnm

On Wed, 2020-02-26 at 10:08 +0000, António Mendes wrote:
Hi Thomas.

Thank you for your help. I am new using this library so, your help is
much appreciated.
That's really what I was looking for because, right now, I am simply
calling system("nmcli con mod Wired\ connection\ 1 ...") in my test
application to modify settings and I wanted to replace that part.
I will keep you informed.

btw, libnm is glib based, so you can also use it via GObject
introspection, for example from Python or Javascript (gjs).

That tends to be faster for prototyping. See examples

This is also what is done by various other projects:

For larger examples how to use libnm natively, look at


Thanks again,
António Pontinha Mendes
From: Thomas Haller <thaller redhat com>
Sent: 25 February 2020 17:34
To: António Mendes; networkmanager-list gnome org
Subject: Re: Change IP address with libnm

On Tue, 2020-02-25 at 17:02 +0000, António Mendes wrote:
I tried to use the example add-connection-libnm-glib.c and adapt to
my case but without success...
I wanted to change an IP address from a connection already created
and add some 802.1X configurations.


add-connection adds a new profile.
Basically, what `nmcli connection add ...` does.

The example you refer to is about usage of libnm. So, the
API is nm_remote_connection_update2() ([1]). This maps to the D-Bus
call Update2 ([2]). This is what `nmcli connection modify ...` does.


As always, connection profiles in NetworkManager are really just a
bunch of nested
dictionaries, that is the plain settings. There is no further logic
involved, just
create a suitable profile. If you use libnm, you probably create the
profile using the
NMConnection and NMSetting types. These represent the nested

After you modify a profile, you usually need to activate it so that
your actual networking
configuration (`nmcli device`, `ip link`) changes.


Capital Social €1.100.000
N° de matricula unico 501 400 699


Attachment: signature.asc
Description: This is a digitally signed message part

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]