Virtualbox VM setups.

Virtualbox network setup for internet access:

Generally the following table gives the connectivity for different Virtualbox Network adapters. Sometimes it is possible the Bridged network wont get an ipv4 address and cannot connect to internet. Then we have to setup both a NAT and a Host-only adapter network.

The requirement is:

  • Host is Windows 10, Guest VM is Centos 7.5
  • The Centos 7 VM should be able to access the internet
  • The Windows host should be able to ssh to the guest VM.

Table 6.1. Overview

 Adapters VM ↔ Host VM1 ↔ VM2 VM → Internet VM ← Internet
Host-only + +
Internal +
Bridged + + + +
NAT + Port forwarding
NAT Network + + Port forwarding
  1. First try on Virtualbox Settings->Network->Adapter 1->Bridged adapter
  2. Run ifconfig command on the guest VM to see if you get an ipv4 address on enp0s3 adapter. If you see ipv4 address then you may not need to do anything else. Ping 8.8.8.8 from the VM and try to ssh from the Windows host to the VM to see if it works.
  3. If you dont get an ipv4 address then you need to setup both a NAT and Host-only adapter.
  4. Completely Shut down all running VM’s as the Adapter 2 cannot be added when the VM is running or suspended.
  5. In Settings->Network->Adapter 1 set Attached to: NAT
  6. Click on Adapter 2 and set Attached to: Host-only Adapter. Select Name: “VirtualBox Host-only Ethernet Adapter”.  Select the adapter: “Intel PRO/1000 MT Desktop(…”
  7. Click on “Ok” to save all settings and start the VM
  8. Open the terminal
  9. Enter: ifconfig
[root]# ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
 inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
 inet6 fe80::767b:7aa7:c2f0:dfe6 prefixlen 64 scopeid 0x20<link>
 ether 08:00:27:e6:39:88 txqueuelen 1000 (Ethernet)

enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
 inet 192.168.5.123 netmask 255.255.255.0 broadcast 192.168.56.255
 inet6 fe80::3477:1f1a:381d:1a72 prefixlen 64 scopeid 0x20<link>
 ether 08:00:27:79:3a:07 txqueuelen 1000 (Ethernet)

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
 inet 127.0.0.1 netmask 255.0.0.0
 inet6 ::1 prefixlen 128 scopeid 0x10<host>
 loop txqueuelen 1000 (Local Loopback)

10. Now you see a local IP address like: 192.168.5.123The IP address is dynamic an can be different on your VM.

11. Ping the ip from the Windows Host: ping 192.168.5.123

12. ping 8.8.8.8 from the guest Centos VM to see that you can access internet .

Now you can access the internet from your guest VM and access the VM from your windows host using Putty.

13. To be able to access the VM using ssh from a different laptop you will need to change settings under NAT->Advanced->Port Forwarding>add a rule giving both hostip/hostport and Guestip/guestport such as x.x.x.x 22 and 192.168.5.123 22 . Use ipconfig to find you host ip address.

 

Virtualbox hard disk resizing on Centos 7:

This blog has good instructions:

https://linuxhint.com/increase-virtualbox-disk-size/

https://blog.sajjan.com.np/2017/03/30/increase-size-root-partition-centos/

Check if you have LVM using command:

$ lvdisplay

— Logical volume —
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID MbLcbe-H3Xd-YbIx-kaYE-g33Z-WfmB-XdOh6R
LV Write Access read/write
LV Creation host, time localhost, 2018-06-29 16:24:05 -0400
LV Status available

 

You can test the lvextend command before running it using -t option:

# lvextend -t -r -l+100%FREE /dev/mapper/centos-root

TEST MODE: Metadata will NOT be updated and volumes will not be (de)activated.

Size of logical volume centos/root changed from <6.20 GiB (1586 extents) to <21.27 GiB (5444 extents).  Logical volume centos/root successfully resized.

 

 

REFERENCE:

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.