Created
June 11, 2015 15:05
-
-
Save jizhang/335c91770c8d65245a67 to your computer and use it in GitHub Desktop.
Add Route in Windows
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
import re | |
import subprocess | |
ipconfig = subprocess.check_output(['ipconfig']) | |
mo = re.search(r'192\.168\.189\.[0-9]+', ipconfig) | |
vpn = mo.group() | |
ips = [ | |
['192.168.1.100'], | |
['192.168.1.61'], | |
['192.168.1.95'], | |
['192.168.1.93'], | |
['192.168.1.70'], | |
['192.168.1.86'], | |
['192.168.1.24'], | |
['10.0.0.0', '255.0.0.0'] | |
] | |
for ip in ips: | |
if len(ip) == 1: | |
subprocess.check_call(['route', 'add', ip[0], vpn]) | |
else: | |
subprocess.check_call(['route', 'add', ip[0], 'mask', ip[1], vpn]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment