本文整理汇总了Python中mininet.node.Host.setIP方法的典型用法代码示例。如果您正苦于以下问题:Python Host.setIP方法的具体用法?Python Host.setIP怎么用?Python Host.setIP使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.node.Host
的用法示例。
在下文中一共展示了Host.setIP方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ensureRoot
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import setIP [as 别名]
ensureRoot()
timeout = 5
print( "*** Creating nodes" )
h1 = Host( 'h1' )
root = Host( 'root', inNamespace=False )
print( "*** Creating links" )
h1.linkTo( root )
print( h1 )
print( "*** Configuring nodes" )
h1.setIP( '10.0.0.1', 8 )
root.setIP( '10.0.0.2', 8 )
print( "*** Creating banner file" )
f = open( '/tmp/%s.banner' % h1.name, 'w' )
f.write( 'Welcome to %s at %s\n' % ( h1.name, h1.IP() ) )
f.close()
print( "*** Running sshd" )
cmd = '/usr/sbin/sshd -o UseDNS=no -u0 -o "Banner /tmp/%s.banner"' % h1.name
# add arguments from the command line
if len( sys.argv ) > 1:
cmd += ' ' + ' '.join( sys.argv[ 1: ] )
h1.cmd( cmd )
listening = waitListening( server=h1, port=22, timeout=timeout )
示例2: Host
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import setIP [as 别名]
#!/usr/bin/python
"This example doesn't use OpenFlow, but attempts to run sshd in a namespace."
from mininet.node import Host
print "*** Creating nodes"
h1 = Host( 'h1' )
root = Host( 'root', inNamespace=False )
print "*** Creating links"
h1.linkTo( root )
print "*** Configuring nodes"
h1.setIP( h1.intfs[ 0 ], '10.0.0.1', 8 )
root.setIP( root.intfs[ 0 ], '10.0.0.2', 8 )
print "*** Creating banner file"
f = open( '/tmp/%s.banner' % h1.name, 'w' )
f.write( 'Welcome to %s at %s\n' % ( h1.name, h1.IP() ) )
f.close()
print "*** Running sshd"
h1.cmd( '/usr/sbin/sshd -o "Banner /tmp/%s.banner"' % h1.name )
print "*** You may now ssh into", h1.name, "at", h1.IP()
示例3: OVSKernelSwitch
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import setIP [as 别名]
s3 = OVSKernelSwitch( 's3' ,inNamespace=False )
c0 = RemoteController( 'c0', ip = '10.108.100.195' )
c1 = RemoteController( 'c1', ip = '10.108.100.248' )
c2 = RemoteController( 'c2', ip = '10.108.102.176' )
c3 = RemoteController( 'c3', ip = '10.108.101.48' )
l1 = Link( h0, s1 )
Link( h1, s1 )
Link( h2, s2 )
Link( h3, s3 )
Link( s0, s1 )
Link( s0, s2 )
Link( s0, s3 )
h0.setIP( '10.1.0.1/16' )
h1.setIP( '10.1.0.2/16' )
h2.setIP( '10.2.0.1/16' )
h3.setIP( '10.3.0.1/16' )
print h0.cmd('ifconfig')
c0.start()
c1.start()
c2.start()
c3.start()
s0.start( [ c0 ] )
s1.start( [ c1 ] )
s2.start( [ c2 ] )
s3.start( [ c3 ] )
示例4: Host
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import setIP [as 别名]
#!/usr/bin/python
from mininet.topo import Topo
from mininet.node import Host, OVSSwitch, Controller
from mininet.link import Link
h1 = Host('h1')
h2 = Host('h2')
s1 = OVSSwitch('s1', inNamespace=False)
c0 = Controller('c0', inNamespace=False)
Link(h1,s1)
Link(h2,s1)
h1.setIP('10.1/8')
h2.setIP('10.2/8')
c0.start()
s1.start([c0])
print h1.cmd('ping -c1', h2.IP())
s1.stop()
c0.stop()
示例5: ensureRoot
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import setIP [as 别名]
#!/usr/bin/env python
import sys
from mininet.node import Host
from mininet.util import ensureRoot
ensureRoot()
print 'creating nodes...'
h1, root = Host('h1'), Host('root', inNamespace = False)
print 'creating links...'
h1.linkTo(root)
print 'configuring...'
h1.setIP('10.0.0.7', 8)
root.setIP('10.0.0.9', 8)
print 'creating SSH banner...'
f = open('/tmp/%s.banner' % h1.name, 'w')
f.write('Dude! Thanks for dropping into %s at %s, yo!\n' % (h1.name, h1.IP()))
f.close()
print 'running sshd...'
cmd = '/usr/bin/sshd -o UseDNS=no, -u0, -o "Banner /tmp/%s.banner"' % h1.name
h1.cmd(cmd)
print 'ssh into ', h1.name, 'at', h1.IP()
示例6: ensureRoot
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import setIP [as 别名]
ensureRoot()
timeout = 5
info("*** Creating nodes\n")
h1 = Host("h1")
root = Host("root", inNamespace=False)
info("*** Creating link\n")
h1.linkTo(root)
info(h1)
info("*** Configuring nodes\n")
h1.setIP("10.0.0.1", 8)
root.setIP("10.0.0.2", 8)
info("*** Creating banner file\n")
f = open("/tmp/%s.banner" % h1.name, "w")
f.write("Welcome to %s at %s\n" % (h1.name, h1.IP()))
f.close()
info("*** Running sshd\n")
cmd = '/usr/sbin/sshd -o UseDNS=no -u0 -o "Banner /tmp/%s.banner"' % h1.name
# add arguments from the command line
if len(sys.argv) > 1:
cmd += " " + " ".join(sys.argv[1:])
h1.cmd(cmd)
listening = waitListening(server=h1, port=22, timeout=timeout)