以下配置:
Ubuntu 10.04 服务器,2 个 NIC:
- eth0 192.168.1.215/24,默认网关:192.168.1.250
- eth1 192.168.3.225/24
两者都连接到同一个路由器(Funkwerk Bintec R3000)。
路由器可以(通过内置诊断)成功 ping 两个 IP。
当服务器中的两个 NIC 都在线时,从我的本地 PC(IP 为 192.168.1.14/24)我只能 ping 通 eth0,但不能 ping 通 eth1。
但是:当在 ubuntu-box 上禁用 eth0 时,我突然可以 ping eth1!
现在的问题是:我怎样才能让 ubuntu 机器响应 eth0 和 eth1 上的 ping?!
多谢!
编辑:命令输出
ip 地址显示
# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
link/ether 00:0c:29:db:2a:22 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.215/24 brd 192.168.1.255 scope global eth0
inet6 fe80::20c:29ff:fedb:2a22/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:db:2a:2c brd ff:ff:ff:ff:ff:ff
inet 192.168.3.226/24 brd 192.168.3.255 scope global eth1
inet6 fe80::20c:29ff:fedb:2a2c/64 scope link
valid_lft forever preferred_lft forever
ip 链接显示
# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
link/ether 00:0c:29:db:2a:22 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
link/ether 00:0c:29:db:2a:2c brd ff:ff:ff:ff:ff:ff
路线-n
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.3.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 192.168.1.250 0.0.0.0 UG 100 0 0 eth0
ARP 查询
# arp -an
? (192.168.1.200) at 00:0c:29:2d:c6:3b [ether] on eth0
? (192.168.1.222) at 00:0c:29:e9:a4:e5 [ether] on eth0
? (192.168.1.250) at 00:a0:f9:02:4e:01 [ether] on eth0
? (192.168.1.70) at 00:0c:29:a1:21:87 [ether] on eth0
? (192.168.3.250) at 00:a0:f9:02:4e:03 [ether] on eth1
? (192.168.3.201) at 00:0c:29:bb:56:8f [ether] on eth1
? (192.168.1.192) at 00:0c:29:45:6f:46 [ether] on eth0
? (192.168.1.14) at 00:26:18:87:89:cf [ether] on eth0
? (192.168.1.105) at 00:0c:29:4c:8a:30 [ether] on eth0
答案1
您的本地电脑能够 ping 通服务器,因为它与服务器位于同一子网中。
eth0 位于 192.168.1.0 至 192.168.1.255 子网中
eth1 位于 192.168.3.0 至 192.168.3.255 子网中
您的本地 PC 与 eth0 位于同一子网,因此您能够 ping 通 eth0,而不能 ping 通 eth1
答案2
请使用这些设置来评估你是否被臭名昭著的Linux所困扰rp_filter
:
echo 0 > /proc/sys/net/ipv4/conf/eth0/rp_filter ## I think you'll only need this
echo 0 > /proc/sys/net/ipv4/conf/eth1/rp_filter ## Just in case...
假设这有效,我将采取更好的长期配置。
答案3
尝试这个...
echo 0 > /proc/sys/net/ipv4/conf/eth0/rp_filter
echo 0 > /proc/sys/net/ipv4/conf/eth1/rp_filter
编辑 /etc/sysctl.conf
并设置:
net.ipv4.conf.all.rp_filter = 0
并重新加载 sysctl:
sysctl -p