Don't flush ALL routes and enable OPTIONAL default route/gw

fixes #152 hopefully
This commit is contained in:
Bob Lantz
2013-06-17 17:09:54 -07:00
parent 3484389dcd
commit dd21df3ce4
2 changed files with 13 additions and 6 deletions
+1 -1
View File
@@ -260,7 +260,7 @@ class Mininet( object ):
info( host.name + ' ' )
intf = host.defaultIntf()
if intf:
host.configDefault( defaultRoute=intf )
host.configDefault()
else:
# Don't configure nonexistent intf
host.configDefault( ip=None, mac=None )
+12 -5
View File
@@ -418,11 +418,18 @@ class Node( object ):
def setDefaultRoute( self, intf=None ):
"""Set the default route to go through intf.
intf: string, interface name"""
if not intf:
intf = self.defaultIntf()
self.cmd( 'ip route flush root 0/0' )
return self.cmd( 'route add default %s' % intf )
intf: Intf or {dev <intfname> via <gw-ip> ...}"""
# Note setParam won't call us if intf is none
# See if interface is an actual interface
intf = self.intf( 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