I have a server running several Virtualbox instances let's call them v1 to vn

How can I configure these instances in such a way that I can selectively filter traffic for them:


v1 can access the internet completely

v2 can only access the local subnet and incoming traffic is disallowed

v3 can only access the local subnet but incoming traffic is allowed.

The iptables rules are not the problem. But how can I configure Virtualbox that I can filter traffic independently for each virtual machine on the host?

At the moment all Virtualbox machines are running NAT-ed networking. I don't see a way to configure iptables on a vm basis here.

Other options are: bridged networking but here forum messages seem to indicate filtering is not possible.

Host only networking does not allow outgoing traffic as far is I understood it?

Any hints or help is much appreciated!


You can create a host-only adapter (you get a new virtual interface on the host too), which you can then route via your host. Just add the IPs, enable ip forwarding on the host (maybe even NAT if needed), and set up iptables on the FORWARD chain on the host, to filter the traffic as needed.

  • 1
    Absolutely, to the OP: Host only networking puts the VMs on their own switch with the host, then implementing IPTables on the host as mulaz pointed out is the best way to go.
    – MDMoore313
    Mar 13 '13 at 14:11
  • I'm a noob regarding iptables. I assume this way I can also filter outgoing traffic? e.g. based on the internal source port? Mar 13 '13 at 14:19
  • Yes, you can filter traffic going into both directions.
    – mulaz
    Mar 13 '13 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.