Routing traffic from Windows host machine to OpenWrt on Virtualbox

I have Openwrt up and running on Virtualbox on a Windows machine, connected to the modem by ethernet. This means that I do not have a physical router, only a virtual one on Virtualbox. Is there a step by step guide I could follow to route my internet traffic on that Windows machine through the virtual router?

You simply set the network card connected/attached to LAN as a Bridged Interface in VirtualBox (:spiral_notepad: LAN is usually the first interface defined in OpenWrt, WAN is second). The Windows machine should get an IP automatically, as usual.

If you don't wanna use or don't have a second PHY, you can use the Host-Only Adapter (it can be added to a br-lan, but that gets more complex).

It's really out of the scope of OpenWrt on how you connect to the PHYs - but I hope that give you 2 simple methods.

By that you mean i go to network setting for openwrt vm on virtualbox and set Adapter 1 to "bridge adapter" like this?

I immediately lost access to luci and cannot ssh to openwrt at anymore.

I cannot guess:

  1. You have to explain how you're physically connected
  2. I also mentioned host-only
  • Not enough information

  • How did you have access before? (I understood that was the issue you wanted to resolve)

  • Why do you wish to change it?

  • If you had access, then it was setup correctly.

  • Did you bridge LAN in OpenWrtto the other new interface - as I noted?

Adapter 1 was originally Host-only adapter. I changed it following your advice, hopping it would route my windows machine traffic through openwrt.

You didn't follow my advise it seems, then.

So you would bridge a new adapter and the host-only. This is done in OpenWrt.

:spiral_notepad: It may also help if you actually answer - how many PHYs you really have.

1 - the windows machine. I don't have a dedicated router.

I'm really trying to follow but honestly I am new and some of what you say really doesn't make sense to me.



So it was already working, then?

(You failed to mention Windows already had LAN access and IP from the OpenWrt on a host-only adapter.)

Can you provide the results of:

  • tracert - from the Windows machine
  • Traceroute results to from the the LuCI web GUI


:spiral_notepad: To be clear - you setup Adapter 2 as bridged to the Ethernet/ISP, correct?

Screenshot_20230206-063822_Samsung Internet

Currently it is NAT

Disregard. This was before you provided accurate information.

  1. Do not touch Adapter 1
  2. Fix Adapter 2 to connect to Internet



We're on Step 2.

  • Does it work???
  • Traceroute results??

(I don't understand why you told me it's NAT.)

:warning: If you mean you set VirtualBox's Adapter 2 "Attached To" setting as NAT instead of Bridged Adapter, fix this.

currently as NAT it is working. here are the result.

I will try again as bridged


It's working?!?!

Then it's OK, correct?

What are you trying to fix, then?

:spiral_notepad: Please provide both traceroute/tracert results for NAT.
(It's difficult when you don't provide all requested information in a single post.)

With adapter 2 as bridged, luci's traceroute returns "traceroute: can't connect to remote host ( Network unreachable"

I can't upload 2 imgs as new user

If NAT is working - then it should be OK.

(Please follow posts.)


You don't have to take pictures. You can copy/paste. In any case, you still haven't provided the needed information.


over a maximum of 30 hops:

1 13 ms 19 ms 14 ms
2 9 ms 8 ms 8 ms []
3 9 ms 10 ms 9 ms
4 11 ms 10 ms 12 ms []
5 12 ms 13 ms 11 ms
6 14 ms 12 ms 12 ms
7 11 ms 14 ms 13 ms
8 11 ms 10 ms 11 ms []

traceroute to (, 20 hops max, 46 byte packets
1 0.432 ms
2 *
3 *
4 *
5 *
6 *
7 *
8 *
9 *
10 *
11 *
12 *
13 *
14 *
15 *
16 *
17 *
18 *
19 *
20 *

1 Like

Somehow I think your LAN and WAN interfaces are reversed on VirtualBox.

  • In OpenWrt with default settings
  • Adapter 1 should be LAN - connected to a host-only adapter. Windows should get it's IP from the OpenWrt
  • Adapter 2 should be WAN - Bridged to the ISP thru your real PHY

This works in default OpenWrt.

:warning: If you loose connection, make sure both Adapter 1 and Adapter 2 are reset; and you get the correct IP from OpenWrt's LAN on the Windows machine. It is expected you will briefly loose connectivity while fixing this setting.

Is this what you want?

Even after restarting the openwrt vm with that setting and going to luci again, my traceroute is still "Network unreachable"

I also believe we need to clarify, are you by any chance thinking that I am asking how to get openwrt on virtualbox to connect to the Internet? If that's the case then it is not what I am asking. I follow the wiki's guide and have it working already. What I want to ask is how I can pass traffic on the host machine through openwrt on vm first (to apply vpn, QoS, etc.), instead of host machine going directly to internet regardless of openwrt.

I was thinking that indeed, my sincere apologies. Perhaps then, you should clarify the inquiry in your first post (because at least to me, that's exactly what you seem to be asking).

This requires connecting the OpenWrt router on VirtualBox to the Internet. :wink:

  • What does this mean?
  • How do you intend to go "through Openwrt" instead of the host machine going directly to the Internet - but also "regardless" of OpenWrt? :man_shrugging:

If the first boot of an x86 install only finds one eth adapter, it will not create a wan network interface. In that case you would need to create one manually and attach it to the second adapter. The name should be exactly 'wan' (lower case) -- that name is already in the default firewall--, the protocol DHCP Client, and the Device eth1 or whichever virtual port is bridged to the cable modem.