LoginSignup
3
3

More than 5 years have passed since last update.

macでcisco-vpn(Cisco IPsec)を利用した際、ルーティングを自動で設定する方法

Posted at

概要

cisco-vpnのclientは最初からmac用意されている。しかしPPTPなどのプロトコルではできる、routingの設定がなぜかできない。vpn接続先がinternetへoutboundできない場合、ネットが使えなくてこまる。なので、なんとかroutingを書き換える。

下記shellscriptを起動すればOK

#!/bin/bash

if [[ $EUID -ne 0 ]]; then
    echo "Run this as root"
    exit 1
fi

# cisco-vpnを設定したネットワーク(hogehoge)を起動
networksetup -connectpppoeservice hogehoge 

# パスワード入力を待つループ
for i in `seq 1 1 500`
do
    # cisco-vpnのデフォルトのif名はutun。ifconfigで接続確認。
    if ifconfig utun0 > /dev/null 2>&1 ; then
        # routing設定 vpnを利用したいipを指定
        route -nv add -net xxx.xxx.xxx.xxx -interface utun0
        # default route変更
        route change default yyy.yyy.yyy.yyy
        # dnsも必要に応じて変更
        networksetup -setdnsservers hogehoge '8.8.8.8'
        break
    fi
    sleep 0.2s
done

3
3
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
3
3