Last active
September 3, 2017 08:56
-
-
Save nak1114/36a5f29590f539bfd732f412b8c746b7 to your computer and use it in GitHub Desktop.
VPN接続時に自動的にroute設定するスクリプト(要管理者権限)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!ruby | |
vpn_name="HOME" | |
vpn_ip="10.22.33" | |
m=/^\s*(\d+)\.{20,}#{vpn_name}$/.match `route print` | |
system "route delete #{vpn_ip}.0" | |
system("route -p add #{vpn_ip}.0 mask 255.255.255.0 #{vpn_ip}.1 METRIC 1 IF "+m[1]) if m | |
puts `route print` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment