new*_*ple 125 networking mac vpn osx-leopard macos
当我从家里连接到我公司的网络(通过 VPN)时,我不想将所有网络流量发送到 VPN。例如,当我在家工作时,我希望能够将我所有的文件备份到家里的 Time Capsule,并且仍然能够访问公司的内部网络。
我正在使用 Leopard 的内置 VPN 客户端。我尝试取消选中“通过 VPN 连接发送所有流量”。如果我这样做,我将无法通过 curl 或 Web 浏览器访问我公司的内部网站(尽管仍然可以访问内部 IP)。如果我可以有选择地选择一组 IP 或域通过 VPN 路由并将其余的保留在我自己的网络上,那将是理想的。这可以通过 Leopard 的内置 VPN 客户端实现吗?
小智 117
使用以下内容创建文件/etc/ppp/ip-up:
#!/bin/sh
/sbin/route add <SUBNET> -interface $1
Run Code Online (Sandbox Code Playgroud)
替换<SUBNET>为子网,您想通过 VPN 路由(例如 192.168.0.0/16)
以 root 身份执行:
chmod 0755 /etc/ppp/ip-up
Run Code Online (Sandbox Code Playgroud)
每次连接到 VPN 时都会执行此文件。
给脚本的参数:
$1:VPN 接口(例如ppp0)$2: 未知,就0我而言$3:VPN服务器的IP$4:VPN网关地址$5:用于局域网连接的常规(非 vpn)网关小智 17
MacOS 上的网络首选项中有一个隐藏功能:您可以对接口进行排序。
打开系统偏好设置 -> 网络 -> 点击gear左下角 ->Set service Order...
将网络接口按照您希望使用的顺序进行排序至关重要。如果您希望所有非局域网数据都进入 VPN,请将 VPN 接口放在顶部。像这样排序
不是这样的:
这样,无需检查以下设置Session Options:
通过 VPN 连接发送所有流量
? L2TP VPN连接测试
Mar*_*ton 11
我想做类似的事情。连接 VPN,然后通过该 VPN 路由其他网络。我最终得到了以下 Applescript:
-- Connect Work VPN
tell application "System Events"
tell network preferences
tell current location
tell service "Work"
connect
tell current configuration
repeat until get connected = true
delay 1
end repeat
end tell
end tell
end tell
end tell
end tell
set gateway to "192.168.1.1"
do shell script "route add 172.16.0.0/16 " & gateway with administrator privileges
Run Code Online (Sandbox Code Playgroud)
您需要更改"Work"VPN 连接的名称、192.168.1.1网关地址以及172.16.0.0/16要路由到的网络地址。可以通过用不同的地址重复最后一行来添加其他网络。