Search code examples
network-programmingvirtualboxopenwrt

How to use a VirtualBox VM as a router to go outside network


I created an VirtualBox VM run openwrt-x86-generic-combined-ext4.vdi, In side the VM, I am able to ping the internal PCs after connected to VPN via vpnc.

now the question is from the Host machine how to setup to connect to the internal PCs via the VM Router.

from the Host, once I change the gateway to 192.168.1.2, i am not able to go out anyway.

thanks a lot.

PS, on host machine only one NIC which is wirelees NIC. is there any Virtual NIC can be install and solve this problem??

HOST IP 192.168.1.33

Guest
config interface loopback
    option ifname   lo
    option proto    static
    option ipaddr   127.0.0.1
    option netmask  255.0.0.0
        config interface wan
        option ifname   eth0
        option proto    dhcp

config interface lan
    option ifname   eth1
    option type     bridge
    option proto    static
    option ipaddr   192.168.1.2
    option netmask  255.255.255.0
    option gateway  192.168.1.254
    option defaultroute 0
    option peerdns  01

Solution

  • I do not really understand question entirely, but it seems to me that there is no difference between real PC and virtual one. Use Bridged Adapter mode, connect your machine to real network and use as real. Besides, you can use up to 4 adapters.

    And if you want to use PC with linux as router, probably this may help How to Enable IP Forwarding in Linux