多个网卡,只有eth0可以ping通

网络工程 路由 ARP
2022-02-20 22:03:03

我有 4 个节点,每个节点有 4 个端口。我想像环一样连接它们而无需开关。我的拓扑如下所示: 在此处输入图像描述 eth2 和 eth3 已关闭。

我的问题是,

如果我在 node2,我可以 ping node1,但我无法 ping node3;

如果我在node3,我可以ping node4,但我不能ping node2;

如果我在 node4 中,我可以 ping node3,但我无法 ping node1;

如果我在 node1,我可以 ping node2,但我无法 ping node4;

这是我的配置: 系统:CentOS 6.5 完整安装

我使用 /etc/sysconfig/network-scripts/ifcfg-eth0 为端口 0 设置静态 IP 等等。

`DEVICE=eth0
TYPE=Ethernet
UUID=xxxxxxxxxxxxxxx
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
IPADDR=10.0.0.101
NETMASK=255.255.255.0
IPV6INIT=no
USERCTL=no
HWADDR=xxxxxxxxxxxx
IPV4_FAILURE_FATAL=yes
NAME="System eth0"`

The IP for node 1 is 10.0.0.101, 10.0.0.102, 10.0.0.103, 10.0.0.104
       for node 2 is 10.0.0.105, 10.0.0.106, 10.0.0.107, 10.0.0.108
       for node 3 is 10.0.0.109, 10.0.0.110, 10.0.0.111, 10.0.0.112
       for node 4 is 10.0.0.113, 10.0.0.114, 10.0.0.115, 10.0.0.116

我的路由表是这样的:

10.0.0.0        0.0.0.0         255.255.255.0   U     0      0        0 eth2
10.0.0.0        0.0.0.0         255.255.255.0   U     0      0        0 eth3
169.254.0.0     0.0.0.0         255.255.0.0     U     1004   0        0 eth2
169.254.0.0     0.0.0.0         255.255.0.0     U     1005   0        0 eth3

还有我的 /etc/sysctl.conf

net.ipv4.ip_forward = 1

net.ipv4.conf.default.rp_filter = 2
net.ipv4.conf.all.rp_filter = 2

net.ipv4.conf.default.accept_source_route = 2
net.ipv4.conf.all.accept_source_route = 2

ping 的错误信息是“Destination host unreachable”,

3个回答

您的所有接口都在同一个子网中。那是行不通的。您的计算机无法确定使用哪个接口发送到每个主机,因为它认为可以从任何接口访问它们。

如果您坚持此配置,请将每个链接设为不同的子网。对于节点1-2链路,使用10.0.1.0/24;对于节点 2-3 链路,使用 10.0.2.0/24;等等

如果您需要所有节点在一个子网和一个 L2 广播域中工作,

添加网桥接口,在其上启用rstp,在网桥接口上分配IP并将物理接口添加到网桥。

/etc/sysconfig/network-scripts/ifcfg-br0

DEVICE=br0
TYPE=Bridge
STP=on
MACADDR=xxxxxxxxxxxx
IPADDR=x.x.x.x
NETMASK=255.255.255.0
ONBOOT=yes
BOOTPROTO=static
USERCTL=no
NM_CONTROLLED=no
DELAY=0
IPV6INIT=yes
IPV6_AUTOCONF=yes

/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
HWADDR=xxxxxxxxxxxx
TYPE=Ethernet
UUID=xxxxxxxxxxxxxxx
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
USERCTL=no
PEERDNS=yes
IPV6INIT=no
BRIDGE=br0

在环形拓扑中,RSTP 要好得多。环形拓扑中的 STP 可以进入无限拓扑重建。linux 中的 RSTP 支持作为 rstpd 守护进程,但我不确定它是否得到很好的支持,并且在通用 Linux 中进行了更新配置。在基于 Linux 内核的 RouterOS 中,RSTP 可以完美运行。

您需要启用桥接。在 Cisco 设备上,集成路由和桥接将是这里的解决方案。您必须检查您的操作系统文档,但看起来 linux 应该能够做到这一点。

https://unix.stackexchange.com/questions/86056/why-does-linux-require-moving-ip-from-eth-interface-to-bridge-interface

https://wiki.linuxfoundation.org/networking/bridge