Run commands when NIC goes up/down

I’m new to Manjaro, and new to using linux on a workstation. I’m trying to become friends with using linux with a DE.
I’ll install some virtualbox VM’s, and I want their network traffic to be routed through a vpn. My approach to this to create a bridge interface. Then make the vpn and the vm’s members of this bridge. I found an default installed application named “advanced network configuration” where I could create bridge interface. Last time I was doing something “advanced” network config in linux was with gentoo, many years ago. Then there was a way to run a command every time a interface came up or down. I want such script to be triggered by the events of up/down on this bridge. On UP I want it to connect the vpn. On DOWN I want it to disconnect the VPN. Where do I enter the commands I want it to run?
Maybe my approach is not a good way at all to do this?

second question: nat rules. Should I create nat rules using iptables commands, or is there a more prefered way for this in manjaro?

networkmanager configuration has the option:


Thanks, but my vpn doesn’t show up there. It’s managed by a company specific commandline utility. So I need to start/stop it by running a command. (I guess it could be set up using the gui in some way, I haven’t looked into what that utility does.)

Btw, your screenshot shows firewall zone. My gui does not show that option. How can I add that?

You probably need to create a dispatcher script that starts your VPN after up. It also can shut it down, while the network service stops.

The Arch Wiki has some simple examples.

This shows all options and variables you can use in your script. It also shows all different actions on which a script can be run.

This is the option and works only with firewalld. I believe it is only added to the KDE NM GUI. But you can use nmcli to add a connection to a zone.

Thanks. That seems to do what I’m looking for.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.