LoginSignup
80

More than 5 years have passed since last update.

MacでコマンドラインからVPN接続

Last updated at Posted at 2014-11-28

仕事上VPN接続をすることが多く、その度にマウスなりトラックパッドでメニューバーから選択するのが億劫だったのでコマンドラインからVPN接続できないかずっと探していましたが、なかなか無かった。
(VPN接続->サーバ作業が多いので、ターミナル操作してることが多い)

下記のようにnetworksetup コマンドを使う方法が見つかりましたが接続はできても切断がなぜかできない。

$ networksetup -connectpppoeservice [VPNサービス名]
$ networksetup -disconnectpppoeservice [VPNサービス名]

コマンドラインからの VPN 接続

それでまた諦めていましたが、VPN接続をする機会がある度にやっぱり気になってさらに探してみた結果行き着いた答えが下記に。

http://superuser.com/questions/358513/start-configured-vpn-from-command-line-osx

scutilというコマンドを使うらしいです。

  • 接続
$ scutil --nc start Foo
  • 切断
$ scutil --nc stop Foo

これでエイリスを設定しておくとターミナル操作しながらコマンドラインからさくっとつなげます。

.zshrc
alias vc='scutil --nc start'
alias vd='scutil --nc stop'
  • 接続
$ vc [VPNサービス名]
  • 切断
$ vd [VPNサービス名]

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
80