2020年7月29日水曜日

macOSのVPNをコマンド行から接続・停止する

macOSのVPNをコマンド行から接続・停止するには以下のようにします

まずVPNの一覧を取得します。
$ scutil --nc list
Available network connection services in the current set (*=enabled):
....
* (Disconnected)   xxxxxx PPP --> L2TP "VPN1"    [PPP:L2TP]
....
$
ここで得られたVPNの名前を使い接続・停止します。接続するには、以下のようにします。
$ sudo scutil --nc start "VPN1" --secret 共有鍵
停止はstopです。
$ sudo scutil --nc stop "VPN1"