LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-10-2017, 12:07 AM   #1
ziphem
Member
 
Registered: Feb 2004
Location: US / EU
Distribution: Fedora 31
Posts: 225

Rep: Reputation: 29
VPN Autoconnect when network ID != home


I've been trying to get this worked out, but to no avail. In /etc/NetworkManager/dispatcher.d I created 02VPN1.

Code:
#!/bin/bash
VPN_CONNECTION_NAME="blah blah"
NetID=$(/usr/sbin/iwgetid -r)
OkNetwork1="Home Wifi"
if [ "$2" = "up" ] && [ $NetID != OkNetwork1 ]; then
        sleep "3s"
        nmcli con up id "${VPN_CONNECTION_NAME}"
fi
...but it always connects to VPN even when my $NetID is OkNetwork1. I'm not a pro, so please excuse any obvious error. Ideally I would like to have several OkNetworks (1, 2, 3), so I guess I'd change to [[ $NetID != OkNetwork1 || $NetID != OkNetwork2 || $NetID != OkNetwork3 ]]. I'm on Fedora 27.

Thanks for any pointers!!

Last edited by ziphem; 12-10-2017 at 12:10 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Help Adding VPN to Home Network Jackpot Linux - Networking 2 10-28-2017 01:32 PM
Run script on boot (also known as: how do I autoconnect to a VPN server?) stx Linux - General 15 11-14-2013 05:56 PM
[SOLVED] Recommended VPN Server for Home Network chimpsky Linux - Server 7 04-27-2013 09:36 AM
Simple VPN to link my home network to my father's and fiancees home networks christiansacks Linux - Networking 3 09-14-2012 01:55 PM
VPN to company over Wireless home network rgeelen Linux - Wireless Networking 1 05-20-2004 10:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration