我疯了,因为我一直试图解决这个问题近一个星期了。
场景:一台服务器具有两个不同的网络设备。每个设备都插入不同的公司子网。
eth0
插入x.y.5.184/29
时eth1
已插入x.y.88.224/27
。我希望服务器在两台设备上监听。
服务器IP的.5.184/29
应是x.y.5.186
,服务器IP的.88.224/27
应x.y.88.253
。我想用Apache运行两个不同的虚拟机,因此服务器应该 - 使用natpf到相应的虚拟机 - 监听x.y.5.186:p1
VM1和x.y.88.253:p2
VM2
x
并且y
由于隐私问题而必须隐藏,但是给出了值。
所以这就是问题:如果我出现eth1
,服务器没有响应eth0
,我真的不知道为什么。
下面是一些输出与两个设备了:
[user@server ~]$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet x.y.5.186 netmask 255.255.255.248 broadcast x.y.5.191
ether <MAC> txqueuelen 1000 (Ethernet)
RX packets 77141 bytes 50779367 (48.4 MiB)
RX errors 27 dropped 0 overruns 26 frame 1
TX packets 83841 bytes 63781133 (60.8 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet x.y.88.253 netmask 255.255.255.224 broadcast x.y.88.255
ether <MAC> txqueuelen 1000 (Ethernet)
RX packets 77911 bytes 6285521 (5.9 MiB)
RX errors 0 dropped 836 overruns 0 frame 0
TX packets 6502 bytes 1057860 (1.0 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 740 bytes 606784 (592.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 740 bytes 606784 (592.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:67:e6:77 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[user@server ~]$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 x.y.5.185 0.0.0.0 UG 0 0 0 eth0
0.0.0.0 x.y.88.225 0.0.0.0 UG 10 0 0 eth1
x.y.5.184 0.0.0.0 255.255.255.248 U 0 0 0 eth0
x.y.88.224 0.0.0.0 255.255.255.224 U 10 0 0 eth1
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
[user@server ~]$ cat /etc/sysconfig/network-scripts/ifcfg-eth0
# ifcfg-eth0
HWADDR=<MAC>
TYPE=Ethernet
BOOTPROTO=none
#DNS1=x.y.company.dns
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV4_ROUTE_METRIC=0
IPV6INIT=no
IPV6_AUTOCONF=no
IPV6_DEFROUTE=no
IPV6_FAILURE_FATAL=no
NAME=SERVER
UUID=<uuid>
DEVICE=eth0
ONBOOT=yes
IPADDR=x.y.5.186
PREFIX=29
GATEWAY=x.y.5.185
[user@server ~]$ cat /etc/sysconfig/network-scripts/ifcfg-eth1
# ifcfg-eth1
HWADDR=<MAC2>
TYPE=Ethernet
BOOTPROTO=none
#DNS1=x.y.company.dns
DEFROUTE=no
IPV4_FAILURE_FATAL=yes
IPV4_ROUTE_METRIC=10
IPV6INIT=no
IPV6_AUTOCONF=no
IPV6_DEFROUTE=no
IPV6_FAILURE_FATAL=no
NAME=CLIENT
UUID=<uuid2>
DEVICE=eth1
ONBOOT=no
IPADDR=x.y.88.253
PREFIX=27
GATEWAY=x.y.88.225
所以我的想法是它可能是一条路线。我删除/etc/sysconfig/network-scripts/route-eth0
和route-eth1
,所以这些都是默认值。
[user@server ~]$ ip route
default via x.y.5.185 dev eth0 proto static
default via x.y.88.225 dev eth1 proto static metric 10
x.y.5.184/29 dev eth0 proto kernel scope link src x.y.5.186
x.y.88.224/27 dev eth1 proto kernel scope link src x.y.88.253 metric 1
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1
我删除了默认路由 eth1
[root@server user]# ip route del default via x.y.88.225 dev eth1 prot
而且仍然没有变化。Ping到eth0
IP失败但如果我删除了其他路由
[root@server user]# ip route del x.y.88.224/27 dev eth1 proto kernel ric 10
eth0
再次工作,每个连接x.y.5.186
再次eth1
工作,但停止工作。据我所知,我用过的指标eth1
应该解决问题,但事实并非如此。有任何想法的路由专家吗?
编辑:新鲜的CentOS
tables