如何将所有stream量绑定到特定网卡上的特定IP?

我将不得不为每个2个networking接口安装一些服务器。 由于我是服务器configuration和networking的新手,我正在尝试模拟虚拟机上的所有内容。

每个服务器将有2个网卡,eth0和eth1。 所有的eth0将连接到一个网关,并通过互联网。 所有eth1将连接到一个专用交换机。 eth0应该用于所有外部stream量(互联网)。 所有服务器之间的通信应该只通过每个服务器的eth1(不使用网关)。

如果我理解一切正确,我必须定义(静态)路线。 我没有真正得到的是networking掩码,如果我必须为每个服务器设置路由,或者如果我必须定义一个具有特定networking掩码的路由来覆盖所有的eth1 IP地址。

我们说:

Server A eth0 has the IP 192.168.1.91 (will be later internet). Server A eth1 has the IP 192.168.1.92 (local network). Server B eth0 has the IP 192.168.1.93 (will be later internet). Server B eth1 has the IP 192.168.1.94 (local network). Server C eth0 has the IP 192.168.1.95 (will be later internet). Server C eth1 has the IP 192.168.1.96 (local network). 

我已经在服务器A上定义了一个路由:

 route add -net 192.168.1.94 netmask 255.255.255.255 dev eth1 route add -net 192.168.1.96 netmask 255.255.255.255 dev eth1 

ip route get 192.168.1.94结果

 192.168.1.94 dev eth1 src 192.168.1.91 

ip route get 192.168.1.96结果

 192.168.1.96 dev eth1 src 192.168.1.91 

如果我理解正确的话,那么到192.168.1.94(和96)的数据包将通过eth1发送。 但为什么是源IP 192.168.1.91,即使这是eth0和eth1将是192.168.1.92? 有没有可能在服务器B上看到服务器A上的每个IP都有请求? 假设我在服务器A上做了一些类似于ping 192.168.1.93的服务,那么我可以在服务器B上检查哪个IP请求来自哪个IP?

你应该能够逃脱只是一个默认的路线。

正如@ RonMaupin所解释的,你的私有networking不需要路由,它是第2层,因此主机可以相互“查找”。 你确实需要在任何重要的configuration中使用私有IP(或主机名)。

对于你的互联网网卡,你可以configuration他们的IP地址,并将系统的默认路由设置为你的互联网网关。

如何做到这一点取决于你使用的是什么,但在CentOS / RedHat / Fedora上,假设你的互联网网关的IP为10.0.0.1,我将编辑/etc/sysconfig/network来添加:

GATEWAY=10.0.0.1