Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|improve this question
up vote 3 down vote accepted

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.

share|improve this answer
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. – BigHomie 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? – mt_ Mar 13 '13 at 14:19
Yes, you can filter traffic going into both directions. – mulaz Mar 13 '13 at 14:20
Thanks! I'll try to implement it now – mt_ Mar 13 '13 at 14:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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