You are not logged in.

#1 2026-01-09 22:05:06

Beemo
Member
Registered: 2024-12-20
Posts: 83

[Solved] Make NetworkManager not create tun interface

Is there a way to make NetworkManager apply a profile to a tun interface, but not create a new tun interface when the original one disappears and deactivate the profile instead?
I have a software that creates a tun interface and assigns it an IP4, and a NetworkManager profile that configures everything else (DNS, route, route-rules). I want the profile to activate / be applied when I run the software to create the tun interface, and deactivate when the software closes and removes the interface. However, currently NM creates a new interface when the original one is removed and stays up.

NetworkManager[794]: <info>  [1767995913.6539] device (ss-tun): state change: activated -> unmanaged (reason 'unmanaged', managed-type: 'removed')
NetworkManager[794]: <info>  [1767995913.6550] policy: auto-activating connection 'ss-tun' (32fa7031-9fa5-43ad-b21e-f682fb5e1668)
NetworkManager[794]: <info>  [1767995913.6565] device (ss-tun): state change: unmanaged -> unavailable (reason 'managed', managed-type: 'external')
NetworkManager[794]: <info>  [1767995913.6577] device (ss-tun): state change: unavailable -> disconnected (reason 'user-requested', managed-type: 'full')
NetworkManager[794]: <info>  [1767995913.6581] device (ss-tun): Activation: starting connection 'ss-tun' (32fa7031-9fa5-43ad-b21e-f682fb5e1668)
NetworkManager[794]: <info>  [1767995913.6584] device (ss-tun): state change: disconnected -> prepare (reason 'none', managed-type: 'full')
NetworkManager[794]: <info>  [1767995913.6587] device (ss-tun): state change: prepare -> config (reason 'none', managed-type: 'full')
NetworkManager[794]: <info>  [1767995913.6591] device (ss-tun): state change: config -> ip-config (reason 'none', managed-type: 'full')
NetworkManager[794]: <info>  [1767995915.6619] device (ss-tun): state change: ip-config -> ip-check (reason 'none', managed-type: 'full')
NetworkManager[794]: <info>  [1767995915.6642] device (ss-tun): state change: ip-check -> secondaries (reason 'none', managed-type: 'full')
NetworkManager[794]: <info>  [1767995915.6645] device (ss-tun): state change: secondaries -> activated (reason 'none', managed-type: 'full')
NetworkManager[794]: <info>  [1767995915.6652] device (ss-tun): Activation: successful, device activated.

Another issue in the post is now split to https://bbs.archlinux.org/viewtopic.php?pid=2282293

Last edited by Beemo (Yesterday 23:19:46)

Offline

#2 2026-01-09 22:25:13

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 72,068

Re: [Solved] Make NetworkManager not create tun interface

"nmcli device down ss-tun"?
Are you btw looking for https://archlinux.org/packages/extra/x8 … trongswan/ ?

Offline

#3 2026-01-09 22:45:49

Beemo
Member
Registered: 2024-12-20
Posts: 83

Re: [Solved] Make NetworkManager not create tun interface

I just tried nmcli dev down, but it deactivates the connection too, and once the tun interface appears again the profile is not activated:

NetworkManager[794]: <info>  [1767998506.4724] device (ss-tun): state change: unmanaged -> unavailable (reason 'connection-assumed', managed-type: 'external')
NetworkManager[794]: <info>  [1767998506.4727] device (ss-tun): state change: unavailable -> disconnected (reason 'connection-assumed', managed-type: 'external')
NetworkManager[794]: <info>  [1767998506.4733] device (ss-tun): Activation: starting connection 'ss-tun' (52d2a421-4dba-4025-9674-78096a192d96)
NetworkManager[794]: <info>  [1767998506.4750] device (ss-tun): state change: disconnected -> prepare (reason 'none', managed-type: 'external')
NetworkManager[794]: <info>  [1767998506.4751] device (ss-tun): state change: prepare -> config (reason 'none', managed-type: 'external')
NetworkManager[794]: <info>  [1767998506.4752] device (ss-tun): state change: config -> ip-config (reason 'none', managed-type: 'external')
NetworkManager[794]: <info>  [1767998506.4755] device (ss-tun): state change: ip-config -> ip-check (reason 'none', managed-type: 'external')
NetworkManager[794]: <info>  [1767998506.5003] device (ss-tun): state change: ip-check -> secondaries (reason 'none', managed-type: 'external')
NetworkManager[794]: <info>  [1767998506.5005] device (ss-tun): state change: secondaries -> activated (reason 'none', managed-type: 'external')
NetworkManager[794]: <info>  [1767998506.5007] device (ss-tun): Activation: successful, device activated.

I just realized the connection ID is different. NM is automatically creating a new connection.
Even with the old profile (by nmcli con up and then start the software) the DNS severs are still not present in sd-resolved.

Last edited by Beemo (2026-01-09 22:56:25)

Offline

#4 2026-01-09 22:46:27

Beemo
Member
Registered: 2024-12-20
Posts: 83

Re: [Solved] Make NetworkManager not create tun interface

seth wrote:

"nmcli device down ss-tun"?
Are you btw looking for https://archlinux.org/packages/extra/x8 … trongswan/ ?

Haha it's not really strongswan

Last edited by Beemo (2026-01-09 22:50:03)

Offline

#5 2026-01-09 23:14:21

Beemo
Member
Registered: 2024-12-20
Posts: 83

Re: [Solved] Make NetworkManager not create tun interface

post split

Last edited by Beemo (2026-01-10 01:32:42)

Offline

#6 2026-01-10 01:03:14

Beemo
Member
Registered: 2024-12-20
Posts: 83

Re: [Solved] Make NetworkManager not create tun interface

post split

Last edited by Beemo (2026-01-10 01:33:02)

Offline

#7 2026-01-10 01:49:21

Beemo
Member
Registered: 2024-12-20
Posts: 83

Re: [Solved] Make NetworkManager not create tun interface

Seems like the choices are either fully managing an interface or not at all, and perhaps for a reason: https://unix.stackexchange.com/question … ap-devices

Offline

#8 2026-01-10 10:06:47

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 72,068

Re: [Solved] Make NetworkManager not create tun interface

it deactivates the connection too, and once the tun interface appears again the profile is not activated

I thought that was the plan?

I want the profile to activate / be applied when I run the software to create the tun interface, and deactivate when the software closes and removes the interface. However, currently NM creates a new interface when the original one is removed and stays up.

The idea would be to explicitly activate/deactivate the interface w/ whatever script you're running (sorry, thought "ss" would refer to strongswan)

Offline

#9 2026-01-10 18:28:39

Beemo
Member
Registered: 2024-12-20
Posts: 83

Re: [Solved] Make NetworkManager not create tun interface

Originally I wanted the profile to deactivate when the interface disappears, like for a physical interface, but it creates a new tun interface instead.

seth wrote:

The idea would be to explicitly activate/deactivate the interface w/ whatever script you're running

Yea seems to be the way.

Offline

#10 Yesterday 21:06:59

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 14,636

Re: [Solved] Make NetworkManager not create tun interface

Beemo, [Closed] is reserved for mods and indicates no more posts can be added to a thread.

Please use another term like [solved] and edit the title.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

Board footer

Powered by FluxBB