无法ping mininet中的主机

问题描述 投票:0回答:1

我在mininet的python中有以下代码,我正在尝试pingall,但未收到任何软件包。我不知道怎么了。当我写h1 ping -c 1 h2时,出现错误:

ping:r1:名称或服务未知

#!/usr/bin/env python2.7

from mininet.cli import CLI
from mininet.net import Mininet
from mininet.nodelib import LinuxBridge
from mininet.log import setLogLevel

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

net = Mininet(switch=LinuxBridge, controller=None)

# create rest of the topology here
h1 = net.addHost('h1', ip=None)
h2 = net.addHost('h2', ip=None)
r1 = net.addHost('r1', ip=None)
r2 = net.addHost('r2', ip=None)

s0 = net.addSwitch('s0')
s1 = net.addSwitch('s1')
s2 = net.addSwitch('s2')

r1.cmd('sysctl -w net.ipv6.conf.all.forwarding=1')
r2.cmd('sysctl -w net.ipv6.conf.all.forwarding=1')

net.addLink(h1, s1)
net.addLink(r1, s1)
net.addLink(r1, s0)
net.addLink(r2, s0)
net.addLink(r2, s2)
net.addLink(h2, s2)

h1.cmd("ip -6 addr add 2001:638:709:a::1/64 dev h1-eth0")
h2.cmd("ip -6 addr add 2001:638:709:b::1/64 dev h2-eth0")
r1.cmd("ip -6 addr add 2001:638:709:a::f/64 dev r1-eth0")
r1.cmd("ip -6 addr add 2001:638:709:f::1/64 dev r1-eth1")
r2.cmd("ip -6 addr add 2001:638:709:f::2/64 dev r2-eth0")
r2.cmd("ip -6 addr add 2001:638:709:b::f/64 dev r2-eth1")

h1.cmd("ip -6 route add 2001:638:709::/48 via 2001:638:709:a::f dev h1-eth0")
r1.cmd("ip -6 route add 2001:638:709:b::/64 via 2001:638:709:f::2 dev r1-eth1")

r2.cmd("ip -6 route add 2001:638:709:a::/64 via 2001:638:709:f::1 dev r2-eth0")

h2.cmd("ip -6 route add 2001:638:709::/48 via 2001:638:709:b::f dev h2-eth0")

net.start()
CLI(net)
net.stop()
mininet
1个回答
0
投票

“名称或服务未知”将表明查找失败,并且名称r1无法解析为IP地址。您可以使用nslookup(或dig)命令进行验证。

© www.soinside.com 2019 - 2024. All rights reserved.