Is it possible to route all traffic on VirtualBox host adapters to guest?

3

I am upgrading Ubuntu 8.04 on a dedicated router/firewall/NAT/SMTP/SSH server with a current Linux (Debian Wheezy). I am using VirtualBox (4.2) with Ubuntu 8.04 as host and the new Debian build as guest. Some preliminary testing has been done, the guest is running well and accessible through a bridged network adapter, and it's time to subject the guest to real traffic.

The host box has two NICs, WAN and LAN, and acts as firewall/NAT between them. I am looking for a way to test the guest's firewall, NAT, and other services, by routing (almost) all network traffic on the host's physical network adapters to the guest's adapters in a predictable way, e.g. guest's eth0 "takes over" all of host's eth0 traffic, and same for eth1.

Can this be done? How, at least in general terms? With rudimentary knowledge in this area, I am not finding an obvious way to proceed and whether this is primarily guest adapter configuration, host routing, port forwarding, or a combination. It would be acceptable for the host to essentially disappear from the network while the test is underway, accessible only through the console (in order to flip the switch back after testing is complete).

For example, although related, this question does not address either taking over all adapter traffic, or keeping a full-strength firewall in place. Same with many other resources found.

mklein9

Posted 2014-04-15T04:34:15.410

Reputation: 131

Ubuntu 8.04 has been EOL since May 9, 2013

– Elliott Frisch – 2014-04-18T17:25:09.167

Sure, but I don't think that's relevant to the question, right? – mklein9 – 2014-04-18T21:00:30.857

That's why it was a comment. – Elliott Frisch – 2014-04-18T22:15:20.060

Answers

2

Passing every packet received on an interface and forwarding on another one is one of the function of bridge. So you need :

  1. Configure the guest VM to use two internal adapter (i.e virtual adapter which connect host and guest. It's one of the possible mode of adapter in VirtualBox VMs.)
  2. Make two bridges in your host
  3. Bridge every guest interface with its respective interface in the host

Be careful! You will lost network access to your host. Use another way (e.g Mouse, keyboard and monitor) to access it.

Jim

Posted 2014-04-15T04:34:15.410

Reputation: 133