Last active
February 13, 2020 12:53
-
-
Save ihciah/a8ae70025bcde808140fb68bb1ba3a24 to your computer and use it in GitHub Desktop.
Set route script for tinc on 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
#!/bin/python | |
# -*- coding: utf-8 -*- | |
# I found the interface id is not a fixed value... | |
import subprocess | |
INTERFACE = "tincvpn" | |
ROUTE = "route add 10.0.0.0 mask 255.0.0.0 192.168.102.199 metric 1 if %s" | |
def get_interface_id(): | |
interfaces = subprocess.check_output("netsh int ipv4 show interfaces") | |
interface_line = filter(lambda x: x.find(INTERFACE) != -1, interfaces.split("\n")) | |
if not len(interface_line): | |
return None | |
interface_num = interface_line[0].split()[0] | |
return interface_num | |
def set_route(): | |
interface = get_interface_id() | |
if interface: | |
subprocess.check_output(ROUTE % interface) | |
if __name__ == "__main__": | |
set_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
python "C:\Program Files (x86)\tinc\tincvpn\set_route.py" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment