Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

94
80

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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サービス名]
94
80
2

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

Qiita Conference 2025 will be held!: 4/23(wed) - 4/25(Fri)

Qiita Conference is the largest tech conference in Qiita!

Keynote Speaker

ymrl、Masanobu Naruse, Takeshi Kano, Junichi Ito, uhyo, Hiroshi Tokumaru, MinoDriven, Minorun, Hiroyuki Sakuraba, tenntenn, drken, konifar

View event details
94
80

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?