diff --git a/examples/sshd.py b/examples/sshd.py
index 932268415844432ca7682438323ed0ba7a39f1ab..e6641181797735cb7b1fe62f4bc4fbd6e28c434c 100755
--- a/examples/sshd.py
+++ b/examples/sshd.py
@@ -37,12 +37,10 @@ def connectToRootNS( network, switch, ip, prefixLen, routes ):
       routes: host networks to route to"""
     # Create a node in root namespace and link to switch 0
     root = Node( 'root', inNamespace=False )
-    port = max( switch.ports.values() ) + 1
-    createLink( root, 0, switch, port )
-    root.setIP( root.intfs[ 0 ], ip, prefixLen )
+    intf = createLink( root, switch )[ 0 ]
+    root.setIP( intf, ip, prefixLen )
     # Start network that now includes link to root namespace
     network.start()
-    intf = root.intfs[ 0 ]
     # Add routes from root ns to hosts
     for route in routes:
         root.cmd( 'route add -net ' + route + ' dev ' + intf )