Esempio n. 1
0
def _setupRouting(endpoint):
	host = endpoint.getHost()
	assert host
	bridge = endpoint.getBridge()
	assert bridge
	id = endpoint.getId()
	assert id
	assert ifaceutil.bridgeExists(host, bridge)
	tincname = _tincName(endpoint)
	assert ifaceutil.interfaceExists(host, tincname)
	assert not ifaceutil.interfaceBridge(host, tincname)
	#enable ip forwarding
	host.execute ("sysctl -q -w net.ipv6.conf.all.forwarding=1");
	host.execute ("sysctl -q -w net.ipv4.conf.all.forwarding=1");
	#add gateway addresses
	for gw in endpoint.getGateways():
		ifaceutil.addAddress(host, bridge, gw)
	#set bridge up
	ifaceutil.ifup(host, bridge)
	ifaceutil.connectInterfaces(host, bridge, tincname, id, endpoint.getGateways())
Esempio n. 2
0
File: tinc.py Progetto: m3z/ToMaTo
def _setupRouting(endpoint):
	host = endpoint.getHost()
	assert host
	bridge = endpoint.getBridge()
	assert bridge
	id = endpoint.getId()
	assert id
	assert ifaceutil.bridgeExists(host, bridge)
	tincname = _tincName(endpoint)
	assert ifaceutil.interfaceExists(host, tincname)
	assert not ifaceutil.interfaceBridge(host, tincname)
	#enable ip forwarding
	host.execute ("sysctl -q -w net.ipv6.conf.all.forwarding=1");
	host.execute ("sysctl -q -w net.ipv4.conf.all.forwarding=1");
	#add gateway addresses
	for gw in endpoint.getGateways():
		ifaceutil.addAddress(host, bridge, gw)
	#set bridge up
	ifaceutil.ifup(host, bridge)
	ifaceutil.connectInterfaces(host, bridge, tincname, id, endpoint.getGateways())
	for gw in endpoint.getGateways():
		ip = gw.split("/")[0]
		util.waitFor(lambda :ifaceutil.reachable(host, ip, iface=bridge))
		assert ifaceutil.reachable(host, ip, iface=bridge), "Cannot reach %s in interface %s" % (ip, bridge)