blob: a714edbe3d375999c204eca7ed4f6c0b26b14671 [file] [log] [blame]
carlosmscabralf40ecd12013-02-01 18:15:58 -02001#!/usr/bin/python
2
3"This example doesn't use OpenFlow, but attempts to run sshd in a namespace."
4
5from mininet.node import Host
6from mininet.util import ensureRoot
7
8ensureRoot()
9
10print "*** Creating nodes"
11h1 = Host( 'h1' )
12
13root = Host( 'root', inNamespace=False )
14
15print "*** Creating links"
16h1.linkTo( root )
17
18print h1
19
20print "*** Configuring nodes"
21h1.setIP( '10.0.0.1', 8 )
22root.setIP( '10.0.0.2', 8 )
23
24print "*** Creating banner file"
25f = open( '/tmp/%s.banner' % h1.name, 'w' )
26f.write( 'Welcome to %s at %s\n' % ( h1.name, h1.IP() ) )
27f.close()
28
29print "*** Running sshd"
30h1.cmd( '/usr/sbin/sshd -o "Banner /tmp/%s.banner"' % h1.name )
31
32print "*** You may now ssh into", h1.name, "at", h1.IP()