LoginSignup
7
5

More than 5 years have passed since last update.

MacOSXのVPN接続をコマンドラインから実行する

Posted at

下記をbashrcとかに書く
"ここをVPN名にする"をMacのシステム設定から追加したVPN名にする。

function vpn-connect {
/usr/bin/env osascript <<-EOF
tell application "System Events"
        tell current location of network preferences
                set VPN to service "ここをVPN名にする" -- your VPN name here
                if exists VPN then connect VPN
                repeat while (current configuration of VPN is not connected)
                    delay 1
                end repeat
        end tell
end tell
EOF
}

function vpn-disconnect {
/usr/bin/env osascript <<-EOF
tell application "System Events"
        tell current location of network preferences
                set VPN to service "ここをVPN名にする" -- your VPN name here
                if exists VPN then disconnect VPN
        end tell
end tell
return
EOF
}

ついかしたら、source ~/.bashrcなどとして設定をリロードする。

7
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
5