Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Automatically start vpn on boot up ?

If none of the specific sub-forums seem right for your thread, ask here.
Message
Author
parkerc
Posts: 22
Joined: 2020-02-22 09:19

Re: Automatically start vpn on boot up ?

#31 Post by parkerc »

:oops: - that was it !! I’m so sorry...

School-boy error - I had been checking/changing the vpn name to try out other connections, and it looks like the one in up-vpn.sh was slightly different, and that looks like it was the issue.

It’s looking good now :-).

Thank you so much..

parkerc
Posts: 22
Joined: 2020-02-22 09:19

Re: Automatically start vpn on boot up ?

#32 Post by parkerc »

Hi,

I’m noticing that the automatic turning on of the vpn, often fails and I think it’s because it occurs too quickly - as running it again it normally works.

Is there a way to slightly delay the execution of the up-vpn.sh script ?

Or is there maybe a way it could retry the connection again, if first unsuccessful (e.g try up to 5 times if needed before reporting a failure?)

Chrisdb
Posts: 279
Joined: 2018-04-10 07:16

Re: Automatically start vpn on boot up ?

#33 Post by Chrisdb »

parkerc wrote:Hi,

I’m noticing that the automatic turning on of the vpn, often fails and I think it’s because it occurs too quickly - as running it again it normally works.
It cannot start too quickly as the script is only started when the interface is up and running (issued by event).

check journal:

Code: Select all

sudo journalctl -u NetworkManager-dispatcher.service
oliverm wrote: I have the same problems.I’m really interested in all VPN world, so would be great if you do more this type of question and answers about how/where/when to use a VPN
Start a new thread with your question.

parkerc
Posts: 22
Joined: 2020-02-22 09:19

Re: Automatically start vpn on boot up ?

#34 Post by parkerc »

Thanks @Chrisdb
Chrisdb wrote: It cannot start too quickly as the script is only started when the interface is up and running (issued by event).

check journal:

Code: Select all

sudo journalctl -u NetworkManager-dispatcher.service
This was what was reported in the journal...

Code: Select all

-- Logs begin at Wed 2020-03-04 19:57:43 GMT, end at Thu 2020-03-05 14:02:02 GMT. --
Mar 04 19:57:55 debian-x234 systemd[1]: Starting Network Manager Script Dispatcher Service...
Mar 04 19:57:55 debian-x234 systemd[1]: Started Network Manager Script Dispatcher Service.
Mar 04 19:57:57 debian-x234 nm-dispatcher[569]: req:1 'hostname': new request (2 scripts)
Mar 04 19:57:57 debian-x234 nm-dispatcher[569]: req:1 'hostname': start running ordered scripts...
Mar 04 19:57:58 debian-x234 nm-dispatcher[569]: req:2 'connectivity-change': new request (2 scripts)
Mar 04 19:57:58 debian-x234 nm-dispatcher[569]: req:2 'connectivity-change': start running ordered scripts...
Mar 04 19:58:04 debian-x234 nm-dispatcher[569]: req:3 'up' [ens3]: new request (2 scripts)
Mar 04 19:58:04 debian-x234 nm-dispatcher[569]: req:3 'up' [ens3]: start running ordered scripts...
Mar 04 19:58:04 debian-x234 nm-dispatcher[569]: req:4 'connectivity-change': new request (2 scripts)
Mar 04 19:59:12 debian-x234 nm-dispatcher[569]: Error: Connection activation failed: The connection attempt timed out
Mar 04 19:59:12 debian-x234 nm-dispatcher[569]: req:3 'up' [ens3], "/etc/NetworkManager/dispatcher.d/up-vpn.sh": complete: failed with Script '/etc/NetworkManager/dispatcher.d/up-vpn.sh' exited with error status 4.
Mar 04 19:59:12 debian-x234 nm-dispatcher[569]: req:4 'connectivity-change': start running ordered scripts...
Mar 04 19:59:22 debian-x234 systemd[1]: NetworkManager-dispatcher.service: Succeeded.

Chrisdb
Posts: 279
Joined: 2018-04-10 07:16

Re: Automatically start vpn on boot up ?

#35 Post by Chrisdb »

The connection attempt timed out...strange...

You're sure the following command works if you run it manually:

Code: Select all

sudo nmcli connection up id "$VPN_NAME"
There's not much more to go on here, we have to enable extra logging.
Edit the file '/etc/NetworkManager/NetworkManager.conf' and add (or change to INFO):

Code: Select all

[logging]
level=DEBUG
Then reboot and check the journal again with the command I provided before.

Also just to be sure, post your final 'up-vpn.sh' file.

EDIT:
Can you also post output of file: '/var/log/messages'

parkerc
Posts: 22
Joined: 2020-02-22 09:19

Re: Automatically start vpn on boot up ?

#36 Post by parkerc »

Here’s the more detailed log file after the VMs has booted up.

Code: Select all

 - Logs begin at Wed 2020-03-11 22:24:00 GMT, end at Wed 2020-03-11 22:26:56 GMT. --
Mar 11 22:24:08 debian-x234 systemd[1]: Starting Network Manager Script Dispatcher Service...
Mar 11 22:24:08 debian-x234 systemd[1]: Started Network Manager Script Dispatcher Service.
Mar 11 22:24:09 debian-x234 nm-dispatcher[550]: req:1 'hostname': new request (2 scripts)
Mar 11 22:24:09 debian-x234 nm-dispatcher[550]: req:1 'hostname': environment: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Mar 11 22:24:09 debian-x234 nm-dispatcher[550]: req:1 'hostname': environment: NM_DISPATCHER_ACTION=hostname
Mar 11 22:24:09 debian-x234 nm-dispatcher[550]: req:1 'hostname': start running ordered scripts...
Mar 11 22:24:09 debian-x234 nm-dispatcher[550]: req:1 'hostname', "/etc/NetworkManager/dispatcher.d/01-ifupdown": run script
Mar 11 22:24:09 debian-x234 nm-dispatcher[550]: req:1 'hostname', "/etc/NetworkManager/dispatcher.d/01-ifupdown": complete
Mar 11 22:24:09 debian-x234 nm-dispatcher[550]: req:1 'hostname', "/etc/NetworkManager/dispatcher.d/up-vpn.sh": run script
Mar 11 22:24:09 debian-x234 nm-dispatcher[550]: req:1 'hostname', "/etc/NetworkManager/dispatcher.d/up-vpn.sh": complete
Mar 11 22:24:09 debian-x234 nm-dispatcher[550]: req:1 'hostname': completed (2 scripts)
Mar 11 22:24:10 debian-x234 nm-dispatcher[550]: req:2 'connectivity-change': new request (2 scripts)
Mar 11 22:24:10 debian-x234 nm-dispatcher[550]: req:2 'connectivity-change': environment: CONNECTIVITY_STATE=NONE
Mar 11 22:24:10 debian-x234 nm-dispatcher[550]: req:2 'connectivity-change': environment: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Mar 11 22:24:10 debian-x234 nm-dispatcher[550]: req:2 'connectivity-change': environment: NM_DISPATCHER_ACTION=connectivity-change
Mar 11 22:24:10 debian-x234 nm-dispatcher[550]: req:2 'connectivity-change': start running ordered scripts...
Mar 11 22:24:10 debian-x234 nm-dispatcher[550]: req:2 'connectivity-change', "/etc/NetworkManager/dispatcher.d/01-ifupdown": run script
Mar 11 22:24:10 debian-x234 nm-dispatcher[550]: req:2 'connectivity-change', "/etc/NetworkManager/dispatcher.d/01-ifupdown": complete
Mar 11 22:24:10 debian-x234 nm-dispatcher[550]: req:2 'connectivity-change', "/etc/NetworkManager/dispatcher.d/up-vpn.sh": run script
Mar 11 22:24:10 debian-x234 nm-dispatcher[550]: req:2 'connectivity-change', "/etc/NetworkManager/dispatcher.d/up-vpn.sh": complete
Mar 11 22:24:10 debian-x234 nm-dispatcher[550]: req:2 'connectivity-change': completed (2 scripts)
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: new request (2 scripts)
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: CONNECTION_DBUS_PATH=/org/freedesktop/NetworkManager/Settings/1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: CONNECTION_FILENAME=/etc/NetworkManager/system-connections/Wired connection 1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: CONNECTION_UUID=21293ade-0112-y44de-b09b-5f06au9ecaa50
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: CONNECTION_ID=Wired connection 1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DEVICE_IFACE=ens3
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DEVICE_IP_IFACE=ens3
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: IP4_ADDRESS_0=192.168.1.110/24 192.168.1.1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: IP4_NUM_ADDRESSES=1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: IP4_GATEWAY=192.168.1.1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: IP4_NAMESERVERS=192.168.1.1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: IP4_DOMAINS=localdomain
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: IP4_ROUTE_0=192.168.1.0/24 0.0.0.0 100
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: IP4_NUM_ROUTES=1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: IP6_ADDRESS_0=fe80::5054:ff:fed4:1c85/64 0.0.0.0
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: IP6_NUM_ADDRESSES=1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: IP6_GATEWAY=0.0.0.0
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: IP6_ROUTE_0=fe80::/64 :: 100
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: IP6_ROUTE_1=ff00::/8 :: 256
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: IP6_NUM_ROUTES=2
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_BROADCAST_ADDRESS=192.168.1.255
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_DAD_WAIT_TIME=0
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_DHCP_LEASE_TIME=86400
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_DHCP_MESSAGE_TYPE=5
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_DHCP_SERVER_IDENTIFIER=192.168.1.1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_DOMAIN_NAME=localdomain
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_DOMAIN_NAME_SERVERS=192.168.1.1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_DOMAIN_SEARCH=localdomain.
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_EXPIRY=1584051851
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_IP_ADDRESS=192.168.1.110
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_NETWORK_NUMBER=192.168.1.0
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_NEXT_SERVER=0.0.0.0
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_REQUESTED_BROADCAST_ADDRESS=1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_REQUESTED_DOMAIN_NAME=1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_REQUESTED_DOMAIN_NAME_SERVERS=1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_REQUESTED_DOMAIN_SEARCH=1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_REQUESTED_HOST_NAME=1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_REQUESTED_INTERFACE_MTU=1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_REQUESTED_MS_CLASSLESS_STATIC_ROUTES=1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_REQUESTED_NETBIOS_NAME_SERVERS=1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_REQUESTED_NETBIOS_SCOPE=1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_REQUESTED_NTP_SERVERS=1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_REQUESTED_RFC3442_CLASSLESS_STATIC_ROUTES=1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_REQUESTED_ROOT_PATH=1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_REQUESTED_ROUTERS=1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_REQUESTED_STATIC_ROUTES=1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_REQUESTED_SUBNET_MASK=1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_REQUESTED_TIME_OFFSET=1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_REQUESTED_WPAD=1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_ROUTERS=192.168.1.1
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: DHCP4_SUBNET_MASK=255.255.255.0
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: environment: NM_DISPATCHER_ACTION=up
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: start running ordered scripts...
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3], "/etc/NetworkManager/dispatcher.d/01-ifupdown": run script
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:4 'connectivity-change': new request (2 scripts)
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:4 'connectivity-change': environment: CONNECTIVITY_STATE=FULL
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:4 'connectivity-change': environment: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Mar 11 22:24:11 debian-x234 nm-dispatcher[550]: req:4 'connectivity-change': environment: NM_DISPATCHER_ACTION=connectivity-change
Mar 11 22:24:14 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3], "/etc/NetworkManager/dispatcher.d/01-ifupdown": complete
Mar 11 22:24:14 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3], "/etc/NetworkManager/dispatcher.d/up-vpn.sh": run script
Mar 11 22:25:15 debian-x234 nm-dispatcher[550]: Error: Connection activation failed: The connection attempt timed out
Mar 11 22:25:15 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3], "/etc/NetworkManager/dispatcher.d/up-vpn.sh": complete: failed with Script '/etc/NetworkManager/disMar 11 22:25:15 debian-x234 nm-dispatcher[550]: req:3 'up' [ens3]: completed (2 scripts)
Mar 11 22:25:15 debian-x234 nm-dispatcher[550]: req:4 'connectivity-change': start running ordered scripts...
Mar 11 22:25:15 debian-x234 nm-dispatcher[550]: req:4 'connectivity-change', "/etc/NetworkManager/dispatcher.d/01-ifupdown": run script
Mar 11 22:25:15 debian-x234 nm-dispatcher[550]: req:4 'connectivity-change', "/etc/NetworkManager/dispatcher.d/01-ifupdown": complete
Mar 11 22:25:15 debian-x234 nm-dispatcher[550]: req:4 'connectivity-change', "/etc/NetworkManager/dispatcher.d/up-vpn.sh": run script
Mar 11 22:25:15 debian-x234 nm-dispatcher[550]: req:4 'connectivity-change', "/etc/NetworkManager/dispatcher.d/up-vpn.sh": complete
Mar 11 22:25:15 debian-x234 nm-dispatcher[550]: req:4 'connectivity-change': completed (2 scripts)
Mar 11 22:25:25 debian-x234 systemd[1]: NetworkManager-dispatcher.service: Succeeded
Trying this command remotely via SSH also now fails, but if I log in via VNC and run it it works ! Weird !

Code: Select all

 sudo nmcli connection up id "$VPN_NAME"
The up-vpn.sh is below.

Code: Select all

 # http://forums.debian.net/viewtopic.php?f=10&t=145355

#!/bin/sh
VPN_NAME="nl2-nodecentral-udp-udp"

interface=$1 status=$2
case $status in
  up|vpn-down)
      nmcli connection up id "$VPN_NAME"
    ;;
  down)
      if nmcli connection show --active | grep "$VPN_NAME"; then
        nmcli connection down id "$VPN_NAME"
      fi
    ;;
esac


# Also to enable dispatcher, run:
# sudo systemctl enable NetworkManager-dispatcher.service

Chrisdb
Posts: 279
Joined: 2018-04-10 07:16

Re: Automatically start vpn on boot up ?

#37 Post by Chrisdb »

what is the content of the '01-ifupdown' file?

Remove the following lines from your script:

Code: Select all

# http://forums.debian.net/viewtopic.php?f=10&t=145355

# Also to enable dispatcher, run:
# sudo systemctl enable NetworkManager-dispatcher.service
And make sure that:

Code: Select all

#!/bin/sh
is the first line in your file.

Now were going to try something else. Make sure that your 'wired' connection is up.

So the end result would look something like this:

Code: Select all

#!/bin/sh

LAN_INTERFACE="ens3"
VPN_NAME="nl2-nodecentral-udp-udp"

interface=$1 status=$2

if [ "$1" = "$LAN_INTERFACE" ]; then
	case $status in
	  up|vpn-down)
		nmcli connection up id "$VPN_NAME"    
		;;
	  down)    
		if nmcli connection show --active | grep "$VPN_NAME"; then
		  nmcli connection down id "$VPN_NAME"
		fi    
		;;
	esac
fi

parkerc
Posts: 22
Joined: 2020-02-22 09:19

Re: Automatically start vpn on boot up ?

#38 Post by parkerc »

Chrisdb wrote:what is the content of the '01-ifupdown' file?
Here’s the content of 01-ifupdown.sh ..

Code: Select all

 
#!/bin/sh -e
# Script to dispatch NetworkManager events
#
# Runs ifupdown scripts when NetworkManager fiddles with interfaces.
# See NetworkManager(8) for further documentation of the dispatcher events.

# We do not handle connectivity-change events in ifupdown so simply exit at
# this point
if [ "$2" = "connectivity-change" ]; then
    exit 0;
fi

if [ -z "$1" ]; then
    echo "$0: called with no interface" 1>&2
    exit 1;
fi

if [ -n "$IP4_NUM_ADDRESSES" ] && [ "$IP4_NUM_ADDRESSES" -gt 0 ]; then
   ADDRESS_FAMILIES="$ADDRESS_FAMILIES inet"
fi
if [ -n "$IP6_NUM_ADDRESSES" ] && [ "$IP6_NUM_ADDRESSES" -gt 0 ]; then
   ADDRESS_FAMILIES="$ADDRESS_FAMILIES inet6"
fi

# If we have a VPN connection ignore the underlying IP address(es)
if [ "$2" = "vpn-up" ] || [ "$2" = "vpn-down" ]; then
   ADDRESS_FAMILIES=""
fi

if [ -n "$VPN_IP4_NUM_ADDRESSES" ] && [ "$VPN_IP4_NUM_ADDRESSES" -gt 0 ]; then
   ADDRESS_FAMILIES="$ADDRESS_FAMILIES inet"
fi
if [ -n "$VPN_IP6_NUM_ADDRESSES" ] && [ "$VPN_IP6_NUM_ADDRESSES" -gt 0 ]; then
   ADDRESS_FAMILIES="$ADDRESS_FAMILIES inet6"
fi

# We're probably bringing the interface down.
[ -n "$ADDRESS_FAMILIES" ] || ADDRESS_FAMILIES="inet"

# Fake ifupdown environment
export IFACE="$1"
export LOGICAL="$1"
export METHOD="NetworkManager"
export VERBOSITY="0"

for i in $ADDRESS_FAMILIES; do

    export ADDRFAM="$i"

    # Run the right scripts
    case "$2" in
        up|vpn-up)
            export MODE="start"
            export PHASE="post-up"
            run-parts /etc/network/if-up.d
            ;;
        down|vpn-down)
            export MODE="stop"
            export PHASE="post-down"
            run-parts /etc/network/if-post-down.d
            ;;
# pre-up/pre-down not implemented. See
# https://bugzilla.gnome.org/show_bug.cgi?id=387832
#        pre-up)
#            export MODE="start"
#            export PHASE="pre-up"
#            run-parts /etc/network/if-pre-up.d
#            ;;
#        pre-down)
#            export MODE="stop"
#            export PHASE="pre-down"
#            run-parts /etc/network/if-down.d
#            ;;
        hostname|dhcp4-change|dhcp6-change)
            # Do nothing
            ;;
        *)
            echo "$0: called with unknown action \`$2'" 1>&2
            exit 1
            ;;
    esac
done
And I’ve updated the up-vpn.sh to be as you suggested.

Code: Select all

 #!/bin/sh

LAN_INTERFACE="ens3"
VPN_NAME="nl2-nodecentral-udp-udp"

interface=$1 status=$2

if [ "$1" = "$LAN_INTERFACE" ]; then
   case $status in
     up|vpn-down)
      nmcli connection up id "$VPN_NAME"    
      ;;
     down)    
      if nmcli connection show --active | grep "$VPN_NAME"; then
        nmcli connection down id "$VPN_NAME"
      fi    
      ;;
   esac
fi

Post Reply