We know we can always make these 2 machines communicate using Public IP Address, but we are not encourage to do so because it is not secure.
Instead of going through public connection, we would prefer them to communicate privately via Private network. Machines in different VLAN are usually not allow to communicate for security purposes. For example:
Therefore, there are some extra little works to let these 2 machines able to communicate.
Route Add. We add another route in 2 machines manually by using route add command in linux. (For route adding in Windows, please refer to How to Add Persistent Route in Windows )
Here is the scenario and steps:
Machine X in VLAN A with netmask 255.255.255.240, gateway 192.168.8.209
Machine Y in VLAN B with netmask 255.255.255.224, gateway 192.168.9.1
Machine X:
1) Open terminal and go to /etc/sysconfig/network-scripts
cd /etc/sysconfig/network-scripts2) Edit file route-eth1 ( In this scenario, private vlan are using 2nd network card ), or create a new file name route-eth1 if the file is not exists.
nano route-eth13) Type in your command with the following format:
Destination-Network/cidr via Source-Gateway dev Network-CardTo calculate cidr value, refer to this online calculator: http://www.subnet-calculator.com/cidr.php
In this scenario it will be:
192.168.9.0/27 via 192.168.8.209 dev eth14) Save and exit the editor. Restart the network service by typing the following command:
service network restart5) Type in route and you can see the route is already there!
6) Repeat same step in Machine Y but change the command to:
192.168.7.208/28 via 192.168.9.1 dev eth17) Now Machine X can ping to Machine Y~
Guide written by Eddy@CRs