0

I am currently trying to setup a KVM server with two OS (pfsense & Ubuntu Server) on an Ubuntu server with three NICs (enp2s0, enp1s0, & enp3s5). This is the concept I'm trying to do: http://imgur.com/s7QqsMH

What should the /etc/network/interfaces look like? Because virtual interfaces are needed to setup the virtual machines for pfsense and Ubuntu server OS.

[Answer]

I setup the /etc/network/interfaces to look like this:

auto br0
iface br0 inet dhcp
    bridge_ports enp2s0
    bridge_fd 5
    bridge_maxwait 5
    bridge_stp off
auto br1
iface br1 inet dhcp
    bridge_ports enp1s0
    bridge_fd 5
    bridge_maxwait 5
    bridge_stp off
auto br2
iface br2 inet dhcp
    bridge_ports enp2s0
    bridge_fd 5
    bridge_maxwait 5
    bridge_stp off

1 Answers1

2

If you want to have direct connections (meaning to your "real" network and WAN) inside your VMs you need to bridge your interfaces like this (example for a NIC connected to WAN):

auto br0
iface br0 inet static
        address x.x.x.51
        netmask 255.255.255.224
        network x.x.x.32
        broadcast x.x.x.63
        gateway x.x.x.33
    dns-nameservers  8.8.8.8
    bridge_ports enp2s0f0
    bridge_fd 5
    bridge_maxwait 5
    bridge_stp no

And since you basically want to access all NICs via VMs you have to do this for all VMs, e.g. creating br1, br2, too. You also have to have bridge-utils installed on your host.

Though I don't really understand why you attach the 3rd connection, you're basically creating a loop there. Keep in mind that a VM pretty much behaves like a physically separated computer once you use bridging.

Broco
  • 1,919
  • 12
  • 21
  • Sorry for confusing you. There will be two VMs running on the KVM server (that KVM server is running on Ubuntu). One of the VMs will be pfsense while the other VM will be Ubutnu. Total of 1 pfsense and 2 Ubuntu OS on that server. – Atomicbeast101 Jan 10 '17 at 16:03
  • @Atomicbeast101 yes, so far I understood, my problem was that in the image you provided your server has 3 physical NICs and you attached 2 of them to the same switch. I mean you *can* have one physical NIC bridged only to your pfsense-VM and not used by the host at all but I didn't really get the reason behind that, that's all. Basically I'm saying is you don't need the 3rd physical NIC because you can do it this way: http://i.imgur.com/AAPHGor.png – Broco Jan 11 '17 at 09:01
  • As for the connections between enp1s0, virt-if-2, and virt-if-3, do I need to use a vSwitch (Openvswitch) to connect all three of them? If yes, should my /etc/network/interfaces file look like this: http://pastebin.com/2cD4F0bZ. If yes, then should this list of commands work fine? `ovs-vsctl add-port vsw0 enp1s0 && ovs-vsctl add-port vsw0 virt-if-2 && ovs-vsctl add-port vsw0 virt-if-3` I made some changes to the interfaces (enp2s0 is enp1s0, enp1s0 is enp2s5, evm0 is virt-if-1, evm1 is etc...) – Atomicbeast101 Jan 13 '17 at 14:29
  • You're getting way too complicated here. KVM can do the bridging for you, it's built in. Search for "libvirt kvm bridge" and you will be delighted. All you need to do is get a bridge running on your host, kvm handles the rest. – Broco Jan 17 '17 at 08:48