Skip to content

Instantly share code, notes, and snippets.

@nak1114
Last active September 3, 2017 08:56
Show Gist options
  • Save nak1114/36a5f29590f539bfd732f412b8c746b7 to your computer and use it in GitHub Desktop.
Save nak1114/36a5f29590f539bfd732f412b8c746b7 to your computer and use it in GitHub Desktop.
VPN接続時に自動的にroute設定するスクリプト(要管理者権限)
#!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