Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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:

e.g

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
add comment

1 Answer 1

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
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. –  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
add comment

Your Answer

 
discard

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.