예제 #1
0
    
    ip: string
    intf: interface string
    """
    if not intf:
        intf = node.defaultIntf()
    #node.cmd( 'ip route flush root 0/0' )
    #node.cmd( 'route add default %s' % intf )
    node.cmd('route add -net 0.0.0.0 gw %s %s' % (ip, intf))


if __name__ == '__main__':
    setLogLevel('info')
    topo = MyTopo()
    net = alterNet(topo=topo,
                   switch=UserSwitch,
                   controller=partial(RemoteController, ip='192.168.0.2'))
    #s1, s2, s3 = net.switches
    #net.addLink(s1, s2)
    net.start()

    h1, h2 = net.hosts

    # For each host in Subnet A, set up a default route and static ARPs.
    for i, h in enumerate([h1, h2]):
        h.setIP("10.0.%i.%i/24" % (i + 1, i + 1))
        h.setMAC("00:00:00:00:0%i:0%i" % (i + 1, i + 1))
        setDefaultRoute(h, "10.0.%i.128" % (i + 1))

    alterableCLI(net)
    net.stop()
예제 #2
0
    
    ip: string
    intf: interface string
    """
    if not intf:
        intf = node.defaultIntf()
    #node.cmd( 'ip route flush root 0/0' )
    #node.cmd( 'route add default %s' % intf )
    node.cmd('route add -net 0.0.0.0 gw %s %s' % (ip, intf))


if __name__ == '__main__':
    setLogLevel('info')
    topo = MyTopo()
    net = alterNet(topo=topo,
                   switch=UserSwitch,
                   controller=partial(RemoteController, ip='10.128.4.49'))
    s1, s2, s3, s4, s5, s6, s7, s8, s9, s10 = net.switches
    net.addLink(s2, s5)
    net.start()

    h1, h2, h3, h4 = net.hosts

    h1.setIP("10.0.1.1/24")
    h1.setMAC("00:00:00:00:01:01")
    #h1.setARP("10.0.1.128", "00:00:00:01:01:80")
    #h1.setARP("10.0.1.2", "00:00:00:00:01:02")
    setDefaultRoute(h1, "10.0.1.128")

    h2.setIP("7.7.7.7/24")
    h2.setMAC("00:00:00:00:07:07")