Setting up 2 VM subnets each with 2 virtual machines and add routing between them in VirtualBox
I'm going to create 4 virtual machines running on VirtualBox and 2 Subnets with 2 VMs per each subnet and add routing between those 2 subnets.
If you are new to VirtualBox it's better to go thru the network types available in VirtualBox [1]
First you need to enable a new network adapter and attach the network to "Internal network". use the same internal network name for each VM.
After enabling start the VMs and configure each VM as follows in the interface configuration
/etc/network/interfaces
Subnet 01 contains VM01 and VM02
10.1.0.0/24
Subnet 02 contains VM03 and VM04
10.1.1.0/24
Following shows the configuration which should be added to Subnet 01's one VM.
iface eth1 inet static
address 10.1.0.1
netmask 255.255.255.0
network 10.1.0.0
broadcast 10.1.0.255
likewise configure each VM with the relevant configuration
after that stop the interface and start the interface using following commands
sudo ifdown eth1
sudo ifup eth1
you might sometimes need to restart the network-manager service too. in that case use command
sudo service network-manager restart
After configuring subnets you will be able to ping from/to VM01 from/to VM02 and from/to VM03 from/to VM04
By executing following command you will be able to add routing between the subnets
route add -net 10.0.1.0/24 dev eth1 (this is for subnet 02 machines)After enabling start the VMs and configure each VM as follows in the interface configuration
/etc/network/interfaces
Subnet 01 contains VM01 and VM02
10.1.0.0/24
Subnet 02 contains VM03 and VM04
10.1.1.0/24
Following shows the configuration which should be added to Subnet 01's one VM.
iface eth1 inet static
address 10.1.0.1
netmask 255.255.255.0
network 10.1.0.0
broadcast 10.1.0.255
likewise configure each VM with the relevant configuration
after that stop the interface and start the interface using following commands
sudo ifdown eth1
sudo ifup eth1
you might sometimes need to restart the network-manager service too. in that case use command
sudo service network-manager restart
After configuring subnets you will be able to ping from/to VM01 from/to VM02 and from/to VM03 from/to VM04
By executing following command you will be able to add routing between the subnets
you can view the routing table by executing "route -n"
Now you will be able to communicate with each and every node in the two subnets
[1] https://www.virtualbox.org/manual/ch06.html
Comments
Post a Comment