2 uplinks of different subnet, 1 hubs, 2 servers with 1 eth device
Hi everybody,Do anyone knows how to allow 2 servers each with only 1 eth device to use 2 IPs of different subnet ? This problem has annoyed me so long. Could anyone please shed some light on it.
currently I am connecting 2 servers to 1 hubs, with 1 uplinks plugging to the hubs, each server are using 1 ip from the uplink,
say, (assume 192.192.1.0/24 are public IPs and are available)
uplink A : 192.192.1.0/24
gateway A : 192.192.1.0
sever 1 IP: 192.192.1.184
server 2 IP: 192.192.1.190
3 connection to the hubs:
eth0 of server 1 to hubs
eth0 of server 2 to hubs
uplink A to hubs
everything is fine under this setting.
recently I got another uplink with another subnet and the desired configuration are as followed,
assume 192.192.1.0/24 and 169.169.1.208/28 are public IPs and are available
uplink A : 192.192.1.0/24
gateway A : 192.192.1.0
uplink B : 169.169.1.208/28
gateway B : 169.169.1.209
sever 1 IP: 192.192.1.184
sever 1 IP: 169.169.1.214
server 2 IP: 192.192.1.190
server 2 IP: 169.169.1.220
4 connection to hubs
eth0 of server 1 to hubs
eth0 of server 2 to hubs
uplink A to hubs
uplink B to hubs
So I try to plug uplink B to the hubs in addition to previous setting, then all network connection freezed. After reading materials from Internet, I think the cause of the problem is there exists 2 gateways(both uplinks connected to hubs) for the servers to choose, so they simply randomly pick either one and sometimes they choose the wrong one(not of same subnet) and packet cannot go out.
The solution to this problem should be adding static routes to both servers, telling them which gateway to be the corrected one.
As a result, I set up a testing server with 2 eth device to test if my thought works.
here's the testing environment,
uplink A : 192.192.1.0/24
gateway A : 192.192.1.0
uplink B : 169.169.1.208/28
gateway B : 169.169.1.209
sever 1 IP: 192.192.1.184 (can be ignored)
server 2 IP: 192.192.1.190 (can be ignored)
server 3 IP: 192.192.1.188
server 3 IP: 169.169.1.218
connection:
eth0 of server 1 to hubs (can be ignored)
eth0 of server 2 to hubs (can be ignored)
eth0 of server 3 to hubs
uplink A to hubs
uplink B to eth1 of server 3
routing table in server 3:
route add -host 192.192.1.188 gw 192.192.1.0 dev eth0
route add -host 169.169.1.218 gw 169.169.1.209 dev eth1
default gw 192.192.1.0
default gw 169.169.1.209
everything works fine in the testing server (server3) !!
While I am going to put the analogy of 2 eth device to 1 hubs, nightmare comes.
uplink A : 192.192.1.0/24
gateway A : 192.192.1.0
uplink B : 169.169.1.208/28
gateway B : 169.169.1.209
sever 1 IP: 192.192.1.184
server 2 IP: 192.192.1.190
3 connection to hubs
eth0 of server 1 to hubs
eth0 of server 2 to hubs
uplink A to hubs
under this setting, i edit the routing tables to the 2 servers.
server1:
route add -host 192.192.1.184 gw 192.192.1.0 dev eth0
server2:
route add -host 192.192.1.190 gw 192.192.1.0 dev eth0
then what I am going to do is to plug uplink B to the hubs, it is assumed that the packets will simply ignore the newly added gateway 169.169.1.209, as static route has told them to go through 192.192.1.0.
going to do (in order)
uplink B to hubs
sever 1 IP: 169.169.1.214
server 2 IP: 169.169.1.220
server1:
route add -host 169.169.1.214 gw 169.169.1.209 dev eth0
server2:
route add -host 169.169.1.220 gw 169.169.1.209 dev eth0
However, network connection got struck once I plug uplink B to hubs !! I really don't understand its ok for 2 eth device but not 1 hubs with 2 uplinks plugging into it.
Please help !
and thanks you very much!