【问题标题】:Mininet dump information is not updated after an ifconfig command使用 ifconfig 命令后 Mininet 转储信息未更新
【发布时间】:2016-02-04 09:33:04
【问题描述】:

我们将 Mininet 用于教学目的,作为网络模拟器,我们的学生可以在其中定义自己的 IP 网络和路由表。当我们更新网络接口的 IP 地址时,存在一个常见问题。例如,使用 Mininet 的默认拓扑(两台主机和一台交换机,并且两台主机都属于 10.0.0.0/8)如果我们通过ifconfig 更改它们的 IP 地址:

h1 ifconfig h1-eth0 192.168.1.1/24
h2 ifconfig h2-eth0 192.168.1.2/24

然后我们输入dump我们得到以下信息:

<Host h1: h1-eth0:10.0.0.1 pid=1169>
<Host h2: h2-eth0:10.0.0.2 pid=1173>

pingall 命令不起作用。

有没有办法强制通过python方法或类似方法更新信息?我们已经检查过,如果我们向主机发送数据包,信息就会更新,但对于由数十台主机组成的拓扑来说,这是不切实际且繁琐的。

我知道py h1.setIP() 可以解决这个问题,但是对于我们的目的来说,继续使用像ifconfig 这样的操作系统命令而不是使用python 调用是很重要的。

提前致谢。

【问题讨论】:

    标签: python dump mininet ifconfig


    【解决方案1】:

    在 mininet 中,交换机默认创建为二层交换机,并且默认有多个规则。你可以使用

    sh ovs-ofctl dump-flows s1
    

    检查s1中的流规则。

    所以在更改 h1 和 h2 的 IP 地址之前,规则如下:

    NXST_FLOW reply (xid=0x4)
    

    这是空的。

    然后你输入pingall,交换机会根据原来的IP地址(10.0.0.1 & 10.0.0.2)添加规则,可能是这样的:

    NXST_FLOW reply (xid=0x4):
     cookie=0x0, duration=1.376s, table=0, n_packets=2, n_bytes=196, idle_timeout=60, idle_age=1, priority=65535,icmp,in_port=2,vlan_tci=0x0000,dl_src=f6:6b:f6:42:44:ac,dl_dst=06:37:92:eb:2c:a0,nw_src=10.0.0.2,nw_dst=10.0.0.1,nw_tos=0,icmp_type=0,icmp_code=0 actions=output:1
     cookie=0x0, duration=1.375s, table=0, n_packets=1, n_bytes=98, idle_timeout=60, idle_age=1, priority=65535,icmp,in_port=2,vlan_tci=0x0000,dl_src=f6:6b:f6:42:44:ac,dl_dst=06:37:92:eb:2c:a0,nw_src=10.0.0.2,nw_dst=10.0.0.1,nw_tos=0,icmp_type=8,icmp_code=0 actions=output:1
     cookie=0x0, duration=1.374s, table=0, n_packets=1, n_bytes=98, idle_timeout=60, idle_age=1, priority=65535,icmp,in_port=1,vlan_tci=0x0000,dl_src=06:37:92:eb:2c:a0,dl_dst=f6:6b:f6:42:44:ac,nw_src=10.0.0.1,nw_dst=10.0.0.2,nw_tos=0,icmp_type=0,icmp_code=0 actions=output:2
    

    而 mininet 会将“h1”映射到 10.0.0.1,将“h2”映射到 10.0.0.2

    现在如果您将 IP 更改为 192.168.1.1/24 和 192.168.1.2/24。规则仍然适用于 10.0.0.1 和 10.0.0.2。然后在 60 秒空闲超时后,它再次变为空。

    因此,如果您想使用新 IP 相互连接。您可以尝试对主机名使用单 ping,例如:

    h1 ping h2
    h2 ping h2
    

    要更改Mininet中的映射,然后可以再次相互ping通。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-27
      • 2015-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多