INTERNAL NETWORKING MODE IN VIRTUAL BOX MANAGER WITH LAB PRACTICAL

'Internal network' is a networking mode available in virtual box manager tool (see pic 1) , In this mode we can create our own network (with help of subnetting) in our virtual environment which will act like a real one which you see in your companies. In this way , virtual machine can only communicate to other virtual machine with same internal network adapter.
internal network pic 1













Objective:
Create two different internal network and communicate them to each other with the help of routing & ip forwarding rules.

Below is the picture of what our lab network looks like.

internal network pic 2















NOTE:
In our lab test we will use RedHat Linux but you can use any other distro.
Assuming the machines name as  server, client1, client2 as shown in pic 2.

1) First of all create a virtual machine and install all essential required packages (e.g  vim ,  net-tools, open ssh etc ) and upgrade the system with latest packages.

$yum install vim net-tools openssh*
$yum update
$yum upgrade

2) Then clone that machine to create two more machines 
Note: Create new mac addresses, disk names & UUIDs for your new machines





















3) Enable network adapters for your virtual machines as mentioned below

a- Create 2 network adapters for 'server' machine
b-  Create Each 1 network adapters for 'client1' and  'client2' see pic3

4) On server machine set 'Internal Network' in both adapters and type the name as 'net-a' & 'net-b' respectively (see pic 3)















5) On client1 and client2 set adapters as internal network & set net-a on client1net-b on client2













6) Configure the hostname as shown below on all three machines accordingly.

$hostnamectl set-hostname server

internal network pic 4




6a) Edit the hosts file as below

$vi /etc/hosts #open hosts file

$127.0.1.1 server #add this line in hosts file for all three machine with their hostname accordingly

internal network pic 5







7) After that configure static IP addresses for your all three machines.

- check interfaces name with below commands

$ip link show
or 
$ip addr

internal network pic 6









b- configure static ip in all three machines

server:/etc/sysconfig/network-scripts/ifcfg-enp0s8
(if not found then create a new one by copying the default one)
bootproto static
ip add 10.1.1.1
netmask 255.255.255.0
network 10.1.1.0
broadcast 10.1.1.255
name=enp0s8
device=enp0s8
server: /etc/sysconfig/network-scripts/ifcfg-enp0s9
bootproto static
ip add 10.2.2.1
netmask 255.255.255.0
network 10.2.2.0
broadcast 10.2.2.255  #change device, name also
internal network pic 7



client1: /etc/sysconfig/network-scripts/ifcfg-enp08
bootproto static
ip add 10.1.1.10
netmask 255.255.255.0
network 10.1.1.0
broadcast 10.1.1.255   #change device, name also
client2: /etc/sysconfig/network-scripts/ifcfg-enp08
bootproto static
ip add 10.2.2.10
netmask 255.255.255.0
network 10.2.2.0
broadcast 10.2.2.255  #change device,name also
9) Enable the ip forwarding in server machine with below command.
$/sbin/sysctl -w net.ipv4.ip_forward=1
or
add line "net.ipv4.ip_forward = 1" in /etc/sysctl.conf for permanently enable.

internal network pic 8








basically it enables the machine to start routing.

10) Routing configuration on both client machines

add the route network on both client machines by running below command
client1:
route add -net 10.2.2.0 netmask 255.255.255.0 gw 10.1.1.1 dev enp0s8
client2:
route add -net 10.1.1.0 netmask 255.255.255.0 gw 10.2.2.1 dev enp0s8 
internal network pic 9
 
To make the route configuration permanent in your system you have to add routes in

vi /etc/sysconfig/network-scripts/route-enp0s8

in client machines and add the lines (see pic 11,12,13)


internal network pic 10



client 1 
internal network pic 11




client 2
internal network pic 12





That means we are adding the route network of 10.2.2.0 in client1 through interface enp0s8 (interface of client1 machine) which will connected at gateway of 10.1.1.1(server end interface) & same for client2.

11)Now restart the network service in all machines $systemctl restart network or reboot the machines.

Now if you try to ping ip of client2 machine from client1 or vice versa , you are able to do so. thats it.

Note : If you want to connect your these machine to internet or host machine then just create one more adapter in every machine and set that adapter to NAT & create a rule for port forwarding. In this way you can able to access these machine from host machine and also these machine have internet access.





Post a Comment

0 Comments