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.

Current situation:

I have a host running 3 virtual machines. One IP for eth0 (xxx.xxx.xxx.239) and one additional for eth0:1 (yyy.yyy.yyy.35). This works fine for me...

Host (eth0) (xxx.xxx.xxx.239) | 
                              | <- (virbr0) -> |-- VM1 (10.0.0.21)
                                               |-- VM2 (10.0.0.22)
                                               |-- VM3 (10.0.0.23)

...but what I want is to access my third virtual machine addtional by an external IP (yyy.yyy.yyy.35) on one interface and by the second (10.0.0.23) interface for internal purposes:

Host (eth0) (xxx.xxx.xxx.239) | 
                              | <- (virbr0) -> |-- VM1 (10.0.0.21)
                                               |-- VM2 (10.0.0.22)
                                               |-- VM3 (10.0.0.23)

Host (?!?) (?!?)              |
                              |-- VM3 (yyy.yyy.yyy.35)

How to realize this and which iptable rules do I need?

Thanks in advance.

share|improve this question

1 Answer 1

You would be best off by first making eth0 part of a bridge, lets say phybr0. Then assigning an additional NIC to your VM which is bridged to phybr0. And finally letting the VM have the yyy.yyy.yyy.35 address assigned to it from within itself, natively. Also, your host machine will then run its xxx.xxx.xxx.239 IP Address on phybr0, and not eth0. This could be a starting point: http://www.linux-kvm.org/page/Networking#public_bridge .

Otherwise, for a solution involving NAT, look at iptables DNAT. That is fairly simple to implement and examples from the iptables' man page should suffice. I, however, would make myself aware of the limitations of NAT first.

share|improve this answer

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.