2

I'll be on a server with 2 ethernet interfaces, Ubuntu desktop 18.04, virtualization apps including virt-manager and virtualbox

I want to use DHCP from my home router to assign IPs on the bridge, I will have both ethernets plugged into the same router/subnet.

Eventually I want to configure it as static but for now I need to understand how to do it with DHCP.

I think there are different ways to do this. It seems 18.04 has a thing called netplan which changes the way network interfaces are setup.. I'm not real clear on the specifics... But it looks like netplan lets you use network-manager or systemd-networkd to run all your interfaces, depending on your preference.

I think a third option is to configure the bridge using bridge-utils, seems promising.

This page is what lead me to this understanding: https://www.hiroom2.com/2018/05/08/ubuntu-1804-bridge-en/ (VERY interesting site overall, check that guy's stuff out sometime)

So here's my question: How should I setup the bridge for my VMs/containers? What method do I use and why?

I want to plug both of the cables in, and see all my VMs on the net. I just want to know a method that works well.

1 Answer 1

3

It is not clear from your description if you want IPs for VMs to be from your main DHCP or not. If not, then it is easy, KVM comes with its own bridge which is configured automatically after install. Regarding netplan, this is the page I always use as a reference https://www.howtoforge.com/linux-basics-set-a-static-ip-on-ubuntu There are many examples.

Just to configure DHCP for your NIC (watch out for indents, they are important)

network:
 version: 2
 renderer: networkd
 ethernets:
   ens33:
     dhcp4: yes
     dhcp6: yes

and then run netplan apply

Update: After you confirmed you want VMs to receive IPs from the main DHCP server (same as your NIC)

network:
 version: 2
 renderer: networkd
 ethernets:
   ens33:
     dhcp4: no
     dhcp6: no
 bridges:   
   mybridge:   
     interfaces: [ ens33]   
     dhcp4: yes   
     dhcp6: yes
     parameters:   
       stp: false   
       forward-delay: 0

and then run netplan apply.

Of course change the name of your interface You may need to fine-tune this...

What it does is it creates a bridge named mybridge and gets address for it from your DHCP. You can see that the eth interface itself does not get IP, your bridge does.

Then when you define VMs in KVM, you don't use default network but you specify VMs to use mybridge.

1
  • Yes, what I'm looking for is the IPs of the VMs to show up in the same manor as actual devices pluged into my router. I believe what I want is for the VMs to get their DHCP assigned ip from the router directly. Is your example a deal where the server runs DHCP for the VMs? Feb 12, 2019 at 15:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .