4

I have a scenario in which there is a server machine with two interfaces. Each of these interfaces has its own IP address. The server machine hosts an HTTP server, which should be accessible via both of the interfaces.

Full python script to reproduce this situation:

from mininet.cli import CLI
from mininet.log import setLogLevel
from mininet.net import Mininet
from mininet.topo import Topo

class TestTopology(Topo):
    def __init__(self):
        Topo.__init__(self)
        host1_id = self.addHost('h1')
        host2_id = self.addHost('h2')
        server_id = self.addHost('server')
        self.addLink(server_id, host1_id)
        self.addLink(server_id, host2_id)

def configure_network(network):
    server = network.get('server')
    server.setIP('10.0.0.10', intf='server-eth0')
    server.setMAC('00:00:00:00:00:10', intf='server-eth0')
    server.setIP('10.0.0.11', intf='server-eth1')
    server.setMAC('00:00:00:00:00:11', intf='server-eth1')
    server.cmd("python -m SimpleHTTPServer 8080 &")

# Run 'sudo python *path_to_this_script*' in mininet VM.
if __name__ == '__main__':
    setLogLevel('info')
    net = Mininet(topo=TestTopology())
    configure_network(net)
    net.pingAll()
    CLI(net)

The SimpleHTTPServer is listening on 0.0.0.0 as default.

The 'pingAll' test shows that the server is accessible by h1 (and vice versa), but it's not the case for h2. Of course, I can't wget from h2 either.

How to configure the server interfaces so that the server responds both to ping and wget commands via both of these interfaces?

/etc/network/interfaces on the server contains some configuration, but it is regarding a non-existent eth0 interface, so I assumed it is not used.

NOTE: I've already learned that for linux, a particular IP != network interface. The server responds for pings to both 10.0.0.10 and 10.0.0.11 from h1, but I would like for it to respond on both physical interfaces.

bmscicho
  • 139
  • 2
  • 11

2 Answers2

1

You can try importing custom from mininet.util

In my case, reordering the code worked.

Here is my code:

#!/usr/bin/python

from mininet.net import Mininet
from mininet.node import Controller, RemoteController, OVSController
from mininet.node import CPULimitedHost, Host, Node
from mininet.node import OVSKernelSwitch, UserSwitch
from mininet.node import IVSSwitch
from mininet.cli import CLI
from mininet.log import setLogLevel, info
from mininet.link import TCLink, Intf, Link
from mininet.util import makeNumeric, custom
from subprocess import call

def myNetwork():
    link = custom(TCLink, bw=10)
    net = Mininet( topo=None,
                   build=False,
                   ipBase='10.0.0.0/8')

    info( '*** Adding controller\n' )
    info( '*** Add switches\n')



    s5 = net.addSwitch('s5', cls=OVSKernelSwitch, failMode='standalone')
    s2 = net.addSwitch('s2', cls=OVSKernelSwitch, failMode='standalone')
    s7 = net.addSwitch('s7', cls=OVSKernelSwitch, failMode='standalone')
    s4 = net.addSwitch('s4', cls=OVSKernelSwitch, failMode='standalone')

    r8 = net.addHost('r8', cls=Node, ip='0.0.0.0')
    r8.cmd('sysctl -w net.ipv4.ip_forward=1')
    r9 = net.addHost('r9', cls=Node, ip='0.0.0.0')
    r9.cmd('sysctl -w net.ipv4.ip_forward=1')
    r10 = net.addHost('r10', cls=Node, ip='0.0.0.0')
    r10.cmd('sysctl -w net.ipv4.ip_forward=1')

    info( '*** Add hosts\n')
    h1 = net.addHost('h1', cls=Host, ip='192.168.2.1', defaultRoute=None)
    h2 = net.addHost('h2', cls=Host, ip='192.168.3.1', defaultRoute=None)

    info( '*** Add links\n')
    net.addLink(s2, r9)
    net.addLink(s4, r10)
    net.addLink(r9, s5)
    net.addLink(s7, r8)
    net.addLink(r8, h2)
    net.addLink(s5, h2)
    net.addLink(s2, h1)
    net.addLink(s4, h1)
    net.addLink(r10, s7)

    info( '*** Starting network\n')
    net.build()
    info( '*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info( '*** Starting switches\n')
    net.get('s5').start([])
    net.get('s2').start([])
    net.get('s7').start([])
    net.get('s4').start([])

    info( '*** Post configure switches and hosts\n')

    CLI(net)
    net.stop()

if __name__ == '__main__':
    setLogLevel( 'info' )
    myNetwork()
0

I see that you configured the IP address for the both interfaces correctly, but there's no ethernet link connecting the second interface on other hosts, that's why there's no connectivity on that interface. In order to configure it properly, you must:

  1. Create two intf objects and assign their specific IP addresses (10.0.0.10 and 10.0.0.11)
  2. Connect these two interfaces on a switch
  3. Attach both interfaces on the server host
  4. Set up other hosts and/or switches of your topology

I hope it helps to solve the problem...