我不能在Ubuntu上使用Quaggaminet在同一个子网中ping所有内容

2024-04-27 18:41:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我在ping网络拓扑时遇到如下问题(H-->;主机和R-->;路由器):

enter image description here

基本上我想让我所有的pingall网络都在同一个子网(10.0.1.X)中,但使用Quagga Mininet我不能。。。我的接口配置文件(ospfd和zebra)如下所示:

r1ospfd.conf:

! -*- ospf -*-
!
! OSPFd sample configuration file
!
!
hostname r1_ospfd
password en

router ospf
network 10.0.1.0/24 area 0
network 10.0.1.4/30 area 0
network 10.0.1.12/30 area 0
debug ospf packet all send
debug ospf packet all recv
debug ospf zebra
debug ospf event
debug ospf nsm
debug ospf lsa
log stdout
log file /usr/local/etc/r1ospfd.log

r1zebra.conf:

! -*- zebra -*-
!
! zebra sample configuration file
!
! $Id: zebra.conf.sample,v 1.1 2002/12/13 20:15:30 paul Exp $
!
hostname r1_zebra
password en
enable password en
!
! Interface's description.
!
interface r1-eth0
 ip address 10.0.1.10/24
!
interface r1-eth1
 ip address 10.0.1.5/30
!
interface r1-eth2
 ip address 10.0.1.13/30
!
log file /usr/local/etc/r1zebra.log

r2ospfd.conf:

! -*- ospf -*-
!
! OSPFd sample configuration file
!
!
hostname r2_ospfd
password en


router ospf
network 10.0.1.0/24 area 0
network 10.0.1.4/30 area 0
network 10.0.1.16/30 area 0
debug ospf packet all send
debug ospf packet all recv
debug ospf zebra
debug ospf event
debug ospf nsm
debug ospf lsa
log stdout
log file /usr/local/etc/r2ospfd.log

r2zebra.conf:

! -*- zebra -*-
!
! zebra sample configuration file
!
! $Id: zebra.conf.sample,v 1.1 2002/12/13 20:15:30 paul Exp $
!
hostname r2_zebra
password en
enable password en
!
! Interface's description.
!
interface r2-eth0
 ip address 10.0.1.20/24
!
interface r2-eth1
 ip address 10.0.1.6/30
!
interface r2-eth2
 ip address 10.0.1.17/30
!
log file /usr/local/etc/r2zebra.log

r3ospfd.conf

! -*- ospf -*-
!
! OSPFd sample configuration file
!
!
hostname r3_ospfd
password en


router ospf
network 10.0.1.12/30 area 0
network 10.0.1.24/30 area 0
network 10.0.1.32/30 area 0
debug ospf packet all send
debug ospf packet all recv
debug ospf zebra
debug ospf event
debug ospf nsm
debug ospf lsa
log stdout
log file /usr/local/etc/r3ospfd.log

r3zebra.conf:

! -*- zebra -*-
!
! zebra sample configuration file
!
! $Id: zebra.conf.sample,v 1.1 2002/12/13 20:15:30 paul Exp $
!
hostname r3_zebra
password en
enable password en
!
! Interface's description.
!
interface r3-eth1
 ip address 10.0.1.14/30
!
interface r3-eth2
 ip address 10.0.1.25/30
!
interface r3-eth3
 ip address 10.0.1.33/30
!
log file /usr/local/etc/r3zebra.log

r4ospfd.conf:

! -*- ospf -*-
!
! OSPFd sample configuration file
!
!
hostname r4_ospfd
password en


router ospf
network 10.0.1.16/30 area 0
network 10.0.1.24/30 area 0
network 10.0.1.36/30 area 0
debug ospf packet all send
debug ospf packet all recv
debug ospf zebra
debug ospf event
debug ospf nsm
debug ospf lsa
log stdout
log file /usr/local/etc/r4ospfd.log

r4zebra.conf:

! -*- zebra -*-
!
! zebra sample configuration file
!
! $Id: zebra.conf.sample,v 1.1 2002/12/13 20:15:30 paul Exp $
!
hostname r4_zebra
password en
enable password en
!
! Interface's description.
!
interface r4-eth1
 ip address 10.0.1.18/30
!
interface r4-eth2
 ip address 10.0.1.26/30
!
interface r4-eth3
 ip address 10.0.1.37/30
!
log file /usr/local/etc/r4zebra.log

r5ospfd.conf:

! -*- ospf -*-
!
! OSPFd sample configuration file
!
!
hostname r5_ospfd
password en


router ospf
network 10.0.1.0/24 area 0
network 10.0.1.32/30 area 0
network 10.0.1.44/30 area 0
debug ospf packet all send
debug ospf packet all recv
debug ospf zebra
debug ospf event
debug ospf nsm
debug ospf lsa
log stdout
log file /usr/local/etc/r5ospfd.log

r5zebra.conf:

! -*- zebra -*-
!
! zebra sample configuration file
!
! $Id: zebra.conf.sample,v 1.1 2002/12/13 20:15:30 paul Exp $
!
hostname r5_zebra
password en
enable password en
!
! Interface's description.
!
interface r5-eth0
 ip address 10.0.1.30/24
!
interface r5-eth1
 ip address 10.0.1.34/30
!
interface r5-eth2
 ip address 10.0.1.45/30
!
log file /usr/local/etc/r5zebra.log

r6ospfd.conf:

! -*- ospf -*-
!
! OSPFd sample configuration file
!
!
hostname r6_ospfd
password en


router ospf
network 10.0.1.0/24 area 0
network 10.0.1.36/30 area 0
network 10.0.1.44/30 area 0
debug ospf packet all send
debug ospf packet all recv
debug ospf zebra
debug ospf event
debug ospf nsm
debug ospf lsa
log stdout
log file /usr/local/etc/r6ospfd.log

r6zebra.conf:

! -*- zebra -*-
!
! zebra sample configuration file
!
! $Id: zebra.conf.sample,v 1.1 2002/12/13 20:15:30 paul Exp $
!
hostname r6_zebra
password en
enable password en
!
! Interface's description.
!
interface r6-eth0
 ip address 10.0.1.40/24
!
interface r6-eth1
 ip address 10.0.1.38/30
!
interface r6-eth2
 ip address 10.0.1.46/30
!
log file /usr/local/etc/r6zebra.log

这是用于创建网络拓扑的python代码:

#!/usr/bin/python

from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import Node,Controller, RemoteController, OVSSwitch
from mininet.log import setLogLevel, info
from mininet.cli import CLI
from mininet.link import TCLink
import time
import os

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 ):
        
        # ROUTERS
        router1 = self.addNode( 'r1', cls=LinuxRouter, ip='0.0.0.0' )
    router2 = self.addNode( 'r2', cls=LinuxRouter, ip='0.0.0.0' )
        router3 = self.addNode( 'r3', cls=LinuxRouter, ip='0.0.0.0' )
        router4 = self.addNode( 'r4', cls=LinuxRouter, ip='0.0.0.0' )
        router5 = self.addNode( 'r5', cls=LinuxRouter, ip='0.0.0.0' )
        router6 = self.addNode( 'r6', cls=LinuxRouter, ip='0.0.0.0' )

        # HOSTS
        h1 = self.addHost( 'h1', ip='10.0.1.50/24', defaultRoute='via 10.0.1.10') #define gateway
        h2 = self.addHost( 'h2', ip='10.0.1.100/24', defaultRoute='via 10.0.1.20')
        h3 = self.addHost( 'h3', ip='10.0.1.150/24', defaultRoute='via 10.0.1.30')
        h4 = self.addHost( 'h4', ip='10.0.1.200/24', defaultRoute='via 10.0.1.40')

        # LINKS
        self.addLink(h1,router1, intfName2='r1-eth0',params2={ 'ip' : '10.0.1.10/24' }) 
        self.addLink(h2,router2, intfName2='r2-eth0',params2={ 'ip' : '10.0.1.20/24' })
        self.addLink(h3,router5, intfName2='r5-eth0',params2={ 'ip' : '10.0.1.30/24' }) 
        self.addLink(h4,router6, intfName2='r6-eth0',params2={ 'ip' : '10.0.1.40/24' })
        
        self.addLink(router1,router2,intfName1='r1-eth1',intfName2='r2-eth1')
        self.addLink(router1,router3,intfName1='r1-eth2',intfName2='r3-eth1')
        self.addLink(router2,router4,intfName1='r2-eth2',intfName2='r4-eth1')
        self.addLink(router3,router4,intfName1='r3-eth2',intfName2='r4-eth2')
        self.addLink(router3,router5,intfName1='r3-eth3',intfName2='r5-eth1')
        self.addLink(router4,router6,intfName1='r4-eth3',intfName2='r6-eth1')
        self.addLink(router5,router6,intfName1='r5-eth2',intfName2='r6-eth2')
        

def run():
    "Test linux router"
    topo = NetworkTopo()
    net = Mininet(controller = RemoteController, topo=topo) 
    net.start()
    info( '*** Routing Table on Router:\n' )

    r1=net.getNodeByName('r1')
    r2=net.getNodeByName('r2')
    r3=net.getNodeByName('r3')
    r4=net.getNodeByName('r4')
    r5=net.getNodeByName('r5')
    r6=net.getNodeByName('r6')

    info('starting zebra and ospfd service:\n')

    r1.cmd('zebra -f /usr/local/etc/r1zebra.conf -d -z ~/Scrivania/InterfaceApi/r1zebra.api -i ~/Scrivania/InterfaceApi/r1zebra.interface')
    time.sleep(1)
    r2.cmd('zebra -f /usr/local/etc/r2zebra.conf -d -z ~/Scrivania/InterfaceApi/r2zebra.api -i ~/Scrivania/InterfaceApi/r2zebra.interface')
    r3.cmd('zebra -f /usr/local/etc/r3zebra.conf -d -z ~/Scrivania/InterfaceApi/r3zebra.api -i ~/Scrivania/InterfaceApi/r3zebra.interface')
    r4.cmd('zebra -f /usr/local/etc/r4zebra.conf -d -z ~/Scrivania/InterfaceApi/r4zebra.api -i ~/Scrivania/InterfaceApi/r4zebra.interface')
    r5.cmd('zebra -f /usr/local/etc/r5zebra.conf -d -z ~/Scrivania/InterfaceApi/r5zebra.api -i ~/Scrivania/InterfaceApi/r5zebra.interface')
    r6.cmd('zebra -f /usr/local/etc/r6zebra.conf -d -z ~/Scrivania/InterfaceApi/r6zebra.api -i ~/Scrivania/InterfaceApi/r6zebra.interface')

    time.sleep(1)
    r1.cmd('ospfd -f /usr/local/etc/r1ospfd.conf -d -z ~/Scrivania/InterfaceApi/r1zebra.api -i ~/Scrivania/InterfaceApi/r1ospfd.interface')
    time.sleep(1)
    r2.cmd('ospfd -f /usr/local/etc/r2ospfd.conf -d -z ~/Scrivania/InterfaceApi/r2zebra.api -i ~/Scrivania/InterfaceApi/r2ospfd.interface')
    r3.cmd('ospfd -f /usr/local/etc/r3ospfd.conf -d -z ~/Scrivania/InterfaceApi/r3zebra.api -i ~/Scrivania/InterfaceApi/r3ospfd.interface')
    r4.cmd('ospfd -f /usr/local/etc/r4ospfd.conf -d -z ~/Scrivania/InterfaceApi/r4zebra.api -i ~/Scrivania/InterfaceApi/r4ospfd.interface')
    r5.cmd('ospfd -f /usr/local/etc/r5ospfd.conf -d -z ~/Scrivania/InterfaceApi/r5zebra.api -i ~/Scrivania/InterfaceApi/r5ospfd.interface')
    r6.cmd('ospfd -f /usr/local/etc/r6ospfd.conf -d -z ~/Scrivania/InterfaceApi/r6zebra.api -i ~/Scrivania/InterfaceApi/r6ospfd.interface')
 

    info( '*** Routing Table on Router:\n' )
    info( net[ 'r1' ].cmd( 'route' ) )
    time.sleep(1)
    info( net[ 'r2' ].cmd( 'route' ) )
    time.sleep(1)
    info( net[ 'r3' ].cmd( 'route' ) )
    time.sleep(1)
    info( net[ 'r4' ].cmd( 'route' ) )
    time.sleep(1)
    info( net[ 'r5' ].cmd( 'route' ) )
    time.sleep(1)
    info( net[ 'r6' ].cmd( 'route' ) )
    time.sleep(1)

    CLI( net )
    net.stop()
    os.system("killall -9 ospfd zebra")
    os.system("rm -f *api*")
    os.system("rm -f *interface*")

if __name__ == '__main__':
    setLogLevel( 'info' )
    run()

这是pingall me的界面:

enter image description here

我应该换什么?谢谢


Tags: debugselfipcmdlogusrlocalconf