#StackBounty: #virtualbox #virtual-machine #routing #vpn How to route traffic through VPN only accessible within VM (without a bridged …

Bounty: 50

I have an interesting situation where I have a corporate VPN that can only connect through a specific (outdated) version of Ubuntu (and/or Windows) using a vendor-supplied client that creates a VPN interface on tun0 upon successful authentication. I use a different distribution on my personal Linux machine, on which the VPN client will not run because of library issues.

As a workaround, I have more-or-less figured out how to configure the Ubuntu VM (on VirtualBox) to work as a router when the VM is configured in bridge mode. Unfortunately, this works on some networks (like my home one) because I can get another IP no problem for my bridged VM, but on many public networks, this does not work.

I believe I should be able to do this with two network adapters on the VM, one with NAT, and one as a Host-Only connection, but I’m not sure how to set up the routing so that I can send traffic on my host through the VPN tunnel.

Here’s the setup so far:

[host]$ VBoxManage list hostonlyifs 

Name:            vboxnet0
GUID:            786f6276-656e-4074-8000-0a0027000000
DHCP:            Disabled
IPAddress:       192.168.56.1
NetworkMask:     255.255.255.0
IPV6Address:     fe80::800:27ff:fe00:0
IPV6NetworkMaskPrefixLength: 64
HardwareAddress: 0a:00:27:00:00:00
MediumType:      Ethernet
Wireless:        No
Status:          Up
VBoxNetworkName: HostInterfaceNetworking-vboxnet0

The guest interfaces (after connecting to the vpn – enp0s3 is the NAT adapter, enp0s8 is the host-only adapter):

[guest]$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:b2:d9:c2 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic noprefixroute enp0s3
       valid_lft 83176sec preferred_lft 83176sec
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:3c:81:82 brd ff:ff:ff:ff:ff:ff
    inet 192.168.56.101/24 brd 192.168.56.255 scope global dynamic noprefixroute enp0s8
4: tun0: <POINTOPOINT,UP,LOWER_UP> mtu 1384 qdisc fq_codel state UNKNOWN group default qlen 500
    link/none 
    inet XXX.XXX.XXX.XXX peer 1.1.1.1/32 scope global tun0

On the guest, I enable translation between the host-only adapter and the VPN tunnel with the following commands:

sudo sysctl net.ipv4.conf.all.forwarding=1
sudo sysctl net.ipv6.conf.all.forwarding=1
sudo iptables -A FORWARD -i enp0s8 -o tun0 -j ACCEPT
sudo iptables -A FORWARD -i tun0 -o enp0s8 -j ACCEPT
sudo iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE

On the host, I can replace the default route with 192.168.56.1 (the host-only VM adapter), but then obviously no data can get out at all. Since the VM is not getting it’s own access to the internet, I need to have some traffic coming in/out to the internet through the host, but then I would like to force as much as possible of that to go through the VM’s VPN connection. It feels like I’m close, and this should be possible, but I’m not sure what the missing piece is.

On a side note, I think I could get this to work for certain applications by perhaps doing an SSH SOCKS proxy to the VM, perhaps? I’d like to route all traffic through the VPN, if possible.


Get this bounty!!!

#StackBounty: #virtualbox Oracle Virtual Box: How to access USB 2.0 device without using extension pack in windows

Bounty: 50

Is there any way to access an USB 2.0 device in Oracle virtual box without extension pack installed?

I have USB2.0 device in host machine, can I access that device in Guest machine as USB1.1?

I am able to see the device on virtual box device manager with yellow ( driver not supported)
How can I access USB 2.0 device in virtulal box as USB1.1

Oracle VM Version: 5.2.4


Get this bounty!!!

#StackBounty: #windows-10 #virtualbox #centos-7 #vagrant #shared-folders How to share (config.vm.synced_folder), directories between Wi…

Bounty: 50

I’m trying to create a VM CentOS7 using Vagrant (2.2.3) and Virtual Box (6.0.4), on Windows 10 using the following Vagrant file

Vagrant.configure("2") do |config|
  config.vm.box = "bento/centos-7" 
  config.vm.network "private_network", ip: "192.168.56.3"

  config.vm.synced_folder "D://SharedWithVM//CentOS7-Work", "/media/sf_CentOS7-Work", type: "virtualbox"

  config.vm.provider "virtualbox" do |vb|
      vb.name = "Test"
   end
   config.vm.provision "shell", path: "./scripts/InstallGuestAdditions.sh"
end

and the InstallGuestAdditions.sh shell script is the follow ..

#!/bin/bash
curl -C - -O http://download.virtualbox.org/virtualbox/6.0.4/VBoxGuestAdditions_6.0.4.iso
sudo mkdir /media/VBoxGuestAdditions
sudo mount -o loop,ro VBoxGuestAdditions_6.0.4.iso /media/VBoxGuestAdditions
sudo sh /media/VBoxGuestAdditions/VBoxLinuxAdditions.run
rm VBoxGuestAdditions_6.0.4.iso
sudo umount /media/VBoxGuestAdditions
sudo rmdir /media/VBoxGuestAdditions

All works fine and the CentOS7 VM is created.

If I check the machine properties about shared directories I can see this

enter image description here

So I’m quite surprised about this path \?D:SharedWithVMCentOS7-Work.

How should I change my Vagrantfile to obtain a right path?

I’ve tried to connect at my CentOS 7 VM using vagrant ssh command and all works. Also the command cd /media/sf_CentOS7-Work works fine but no file or directory can be listed or shared between the two systems.

I’ve tried to create files or directories in Windows 10 and also in CentOS7 VM.

Any suggestion or example will be appreciated.


Get this bounty!!!

#StackBounty: #linux #usb #virtualbox #vagrant Vagrant gets segmentation fault when trying to add USB

Bounty: 50

I got a simple Vagrantfile that uses archlinux/archlinux and is trying to access a usb that is connected to my host. When I do vagrant up I get an error like this:

There was an error while executing `VBoxManage`, a CLI used by Vagrant 
for controlling VirtualBox. The command and stderr is shown below.
Command: ["showvminfo", "VAGRANT-ID", 
"--machinereadable"]
Stderr: 

If I check it with vboxmanage showvminfo VAGRANT-ID --machinereadable I get a segmentation fault like this:

...
USBFilterManufacturer2=""
USBFilterProduct2=""
USBFilterRemote2=""
USBFilterSerialNumber2=""
[1]    9658 segmentation fault (core dumped)  vboxmanage showvminfo
VAGRANT-ID --machinereadable

The lines I use in my Vagrantfile that tries to access the USB.

vb.customize ["modifyvm", :id, "--usb", "on"]
vb.customize ["modifyvm", :id, "--usbehci", "on"]
vb.customize ['usbfilter', 'add', '0', '--target', :id, '--name', 
'usb', '--vendorid', 'VENDOR-ID-HEX', '--productid', 'PRODUCT-ID-HEX']

My host OS is Fedora 29, Virtualbox version is 6.0 and Vagrant 2.2.3.

Something I’ve tried:

Removed the .vagrent folder and did vagrant up,

Added

vagrant ALL=(ALL) NOPASSWD:ALL
Defaults:vagrant !requiretty

to the /etc/sudoers file

Use the

vboxmanage usbfilter add 0 --taget VAGRANT-ID --name usb 
--vendorid VENDOR-ID-HEX --productid PRODUCT-ID-HEX

(and that gave no error).

Thank you in advance.


Get this bounty!!!