Don't flush ALL routes and enable OPTIONAL default route/gw
fixes #152 hopefully
This commit is contained in:
+1
-1
@@ -260,7 +260,7 @@ class Mininet( object ):
|
|||||||
info( host.name + ' ' )
|
info( host.name + ' ' )
|
||||||
intf = host.defaultIntf()
|
intf = host.defaultIntf()
|
||||||
if intf:
|
if intf:
|
||||||
host.configDefault( defaultRoute=intf )
|
host.configDefault()
|
||||||
else:
|
else:
|
||||||
# Don't configure nonexistent intf
|
# Don't configure nonexistent intf
|
||||||
host.configDefault( ip=None, mac=None )
|
host.configDefault( ip=None, mac=None )
|
||||||
|
|||||||
+12
-5
@@ -418,11 +418,18 @@ class Node( object ):
|
|||||||
|
|
||||||
def setDefaultRoute( self, intf=None ):
|
def setDefaultRoute( self, intf=None ):
|
||||||
"""Set the default route to go through intf.
|
"""Set the default route to go through intf.
|
||||||
intf: string, interface name"""
|
intf: Intf or {dev <intfname> via <gw-ip> ...}"""
|
||||||
if not intf:
|
# Note setParam won't call us if intf is none
|
||||||
intf = self.defaultIntf()
|
# See if interface is an actual interface
|
||||||
self.cmd( 'ip route flush root 0/0' )
|
intf = self.intf( intf )
|
||||||
return self.cmd( 'route add default %s' % intf )
|
if intf in self.ports:
|
||||||
|
params = 'dev %s' % intf
|
||||||
|
elif type( intf ) is str:
|
||||||
|
params = intf
|
||||||
|
else:
|
||||||
|
raise ValueError( 'intf or param string required' )
|
||||||
|
self.cmd( 'ip route del default' )
|
||||||
|
return self.cmd( 'ip route add default dev %s' % intf )
|
||||||
|
|
||||||
# Convenience and configuration methods
|
# Convenience and configuration methods
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user