Connecting 2 routers to 1 Host in mininet
<p>I am attempting to set up a network in which 3 hosts (h1, h2, h3, on different networks) can ping each other through the 2 routers (r1, r2) that separate them. </p>

<p>h1 -> r1 -> h2 -> r2 -> h3 -> r3 -> internet</p>

<p>I found <a href="http://recolog.blogspot.com/2016/02/emulating-networks-with-routers-using.html" rel="nofollow noreferrer">this</a>, to guide me through 2 hosts and 1 router but when I add r2 on the other side of h2, r2 doesn't response to anything, and it isn't able to ping anything OR I can get the following bidirectional pairs:
(h1, r1) (h2, r2)</p>

<p>This code gives me a non-responsive/mute r2:</p>

<pre><code>#!/usr/bin/python
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import Node
from mininet.log import setLogLevel, info
from mininet.cli import CLI

class LinuxRouter( Node ):
    "A Node with IP forwarding enabled."

def config( self, **params ):
    super( LinuxRouter, self).config( **params )
    # Enable forwarding on the router
    self.cmd( 'sysctl net.ipv4.ip_forward=1' )

def terminate( self ):
    self.cmd( 'sysctl net.ipv4.ip_forward=0' )
    super( LinuxRouter, self ).terminate()


class NetworkTopo( Topo ):
    "A LinuxRouter connecting three IP subnets"

def build( self, **_opts ):

    robIP = '10.1.1.14/24'  # IP address for r0-eth1
    richIP = '10.4.4.46/24'
    robert = self.addNode( 'r0', cls=LinuxRouter, ip=robIP, defaultRoute='via 10.4.4.14' )
    richard = self.addNode( 'r1', cls=LinuxRouter, ip=richIP, defaultRoute='via 10.6.6.46' )

    alice = self.addHost( 'h1', ip='10.1.1.17/24', defaultRoute='via 10.1.1.14' )
    bob = self.addHost( 'h2', ip='10.4.4.48/24', defaultRoute='via 10.4.4.14' )

    self.addLink( alice, robert, intfName2='r0-eth1', params2={ 'ip' : '10.1.1.14/24' } )
    self.addLink( bob, robert, intfName2='r1-eth1', params2={ 'ip' : '10.4.4.14/24' } )
    self.addLink( bob, richard, intfName2='r0-eth2', params2={ 'ip' : '10.4.4.46/24' } )



def run():
    "Test linux router"
    topo = NetworkTopo()
    net = Mininet( topo=topo )  # controller is used by s1-s3
    net.start()
    info( '*** Routing Table on Router:\n' )
    print net[ 'r0' ].cmd( 'route' )
    CLI( net )
    net.stop()

if __name__ == '__main__':
    setLogLevel( 'info' )
    run()
</code></pre>

<p>If I transpose these 2 lines I get the 2 bidirectional pairs.</p>

<pre><code>self.addLink( bob, richard, intfName2='r1-eth1', params2={ 'ip' : '10.4.4.46/24' } )
self.addLink( bob, robert, intfName2='r0-eth2', params2={ 'ip' : '10.4.4.14/24' } )
</code></pre>

<p>I don't even know if this problem is my bad code, or if it's a configuration I haven't done on the routers that's causing it. </p>

<p>I just need to be able to pingall with no loss. </p>