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|
|NAT Network||–||+||+||Port forwarding|
- First try on Virtualbox Settings->Network->Adapter 1->Bridged adapter
- 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 18.104.22.168 from the VM and try to ssh from the Windows host to the VM to see if it works.
- If you dont get an ipv4 address then you need to setup both a NAT and Host-only adapter.
- Completely Shut down all running VM’s as the Adapter 2 cannot be added when the VM is running or suspended.
- In Settings->Network->Adapter 1 set Attached to: NAT
- 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(…”
- Click on “Ok” to save all settings and start the VM
- Open the terminal
[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
12. ping 22.214.171.124 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:
Check if you have LVM using command:
— 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.