32. Networking - Agnivo102/Database_Architect GitHub Wiki

Netwroking:

Connect 2 virtual machines with network:

Steps to connect:

Step 1: Change the network adapter settings to both the virtual machines to Beringed adapter from NAT. Remember NAT adapter is required for connecting to internet.

Click on settings



Go to netwerk.



And change the network adapter from NAT to Bringed Adapter.


Step 2: Start both the machines and set the network settings in both of them.

Click on wired settings.



Click on the settings icon next to wired.


In details click on connect automatically



Go to ipv4 and click on manual.



Now go to command prompt of windows and type ipconfig. Now find the Wireless land adapter and find the ipv4 address. Thats what we need.


No go to virtual machine and put the ip address. For example the ip address was 192.168.113.228. Put this address on the virtual machine. 192.168.113.101. Put the netmask 255.255.255.0

This is due to the reason that 192.168.113 these signifies the network which is getting used by both the windows and Linux machine. The windows machine is using 228 with 192.168.113 the complete address being 192.168.113.228. So if the Linux machine also has the complete same Ip address then how can someone differentiate between the windows and Linux machine. So they both need to have slightly different Ip address in the same network (because the source of network between the local machine and virtual machine is same) so that they can be differentiated from each other. So we used 192.168.113.101 (we could have used from 0 to 255 in the 4th section of the address).


Then go to terminal and type ping ip address. If any output come then its working.



Now go to the second virtual machine and do the same steps just put the ip address 192.168.113.102.



Do the same test in the second machine too.

Note: If the Ip of windows changes by ipconfig then change the Ip in the virtual machine manually.

Step 3: Now we can connect to each other machine. For example type ping the 1st machine ip in the second machine. We will get output.



Now both the machine can connect to each other.

Step 4: Now we can send files between both machines. Create a new file ert in 1st machine. Now type scp ert root@ipaddress:/root/


write yes and give the root password of the 2nd machine



and voila. The file is in 2nd machine.



Now create another file in 1st machine. We can directly copy that file from machine 1 directly from machine 2.


Write scp root@ipaddress:/root/newcal /root/ in the second machine and give the root password of the 1st machine.



and see the new file came to the second machine



Note: The command for sending and receiving files.

To send file:

scp (location and file name) user@ipaddress:(where it will be pasted)

scp /home/oracle/sc.sql [email protected]:/home/science/

To receive file:

scp user@ipaddress:(location from where the file will be copied) (ocation where the file will be pasted)

scp [email protected]:/home/oracle/role.sql /home/science/

Now in industry we never share root user. So the procedure is creating another user specifically for sharing and receiving files and sharing that password among the people required to share files.



Connection to putty:

Now that the machine is connected to bringed adapter we can connect it to putty from other machine.


With the ip address we can connect to putty.


If none of the above mentioned network work for connectivity then:

Step 1: Again go to the wired network settings. I have 2 network adapters. Click on the + on the one adapter with bringed adapter. In my vm settings the adapter 1 is the bringed adapter, so i clicked on the first one.

Step 2: Keep the profile name same. Then add the mac address of the bringed adapter one. keep it to automatic. Then click on add. The address it gave you can use it to connect with it.





Remember in the network settings in the VM this must be on. Also as the setting is automatic every time you restart the VM.



Important Note:

Normally with NAT, the VM hides behind the host OS network to access internet. It has no separate IP addesss which can be used for it to find it on internet(The host OS here access the internet for it, and gives the VM what it jeeds from the internet, but in network it doesn't act as a separately computer). So using NAT will not allow SSH or database connection through network as the Computer(basically a VM is a separate computer inside a computer) is in, is not accessible by others in the internet.

Bringed adapter gives the VM a separate ip address which allows it to access the internet by itself not through host OS. So with bringed adapter we can make the VM available for SSH or database connection through internet.