Home Tags About

Mac pptp vpn 自动路由设置

03 Mar 2014
os-x mac vpn pptp



touch /etc/ppp/ip-up /etc/ppp/ip-down
chmod +x /etc/ppp/ip-up /etc/ppp/ip-down

ip-up 脚本可以这么写:

# Script which handles the routing issues as necessary for pppd,
# including for PPTP tunnels. Save this script as /etc/ppp/ip-up
# and make sure it is executable.
# When the ppp link comes up, this script is called with the following
# parameters
ifname=$1        # the interface name used by pppd (e.g. ppp3)
ttyname=$2       # the tty device name
speed=$3         # the tty device speed
localip=$4       # the local IP address for the interface
remoteip=$5      # the remote IP address
ipparam=$6       # the current IP address before connecting to the VPN

case "$remoteip" in
        /sbin/route add -net xxx.xxx.xxx/24 -interface $ifname
        /sbin/route add -host xxx.xxx.xxx.xxx -interface $ifname

exit 0;

ip-down 类似,不过把 add 改成 delete就好了。

查看路由表命令: netstat -nr

Reference: http://www.macfreek.nl/memory/Modify_PPTP_Routing_Table