Last active
March 21, 2017 16:06
-
-
Save maxux/339182e40afc331a3710b547238aee4b to your computer and use it in GitHub Desktop.
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
from g8core import client | |
import sys | |
hosts = { | |
"10.101.200.1": "10.120.0.1", | |
"10.101.200.2": "10.120.0.2", | |
"10.101.200.3": "10.120.0.3", | |
"10.101.200.4": "10.120.0.4" | |
} | |
if len(sys.argv) != 2: | |
print("[-] missing remote host") | |
sys.exit(1) | |
host = sys.argv[1] | |
intf = "enp4s0" | |
print("[+] connecting: %s" % host) | |
cl = client.Client(host) | |
cl.ping() | |
print("[+] starting 40G network: %s" % hosts[host]) | |
test = cl.system("ip l show dev enp4s0").get() | |
if test.stderr != "": | |
intf = "eth0" | |
cl.system("ip l set dev %s mtu 9000" % intf).get() | |
cl.system("ip l add link %s name %s.1234 type vlan id 1234" % (intf, intf)).get() | |
cl.system("ip a add %s/24 dev %s.1234" % (hosts[host], intf)).get() | |
cl.system("ip l set dev %s up" % intf).get() | |
cl.system("ip l set dev %s.1234 up" % intf).get() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment