Why doesn't eth0 get an ip address when set up in a bridge?

5,848

Solution 1

If both interfaces are set up for dhcp, the "tenant interface" cannot receive a dhcp lease before the "host interface". There is no way for eth0 to communicate with dhcp if br0 has no method to communicate on the network. IMO you should set up br0 to be static then have eht0 setup for dhcp.

Solution 2

From here:

Normally it does not make sense to put any L3 protocol address on port interfaces - because incoming packets are diverted to the bridge interface before the L3 protocol is examined. This means the L3 protocol running on the port interface will never see any incoming packets.

(port interface = eth0, bridge interface = br0)

Share:
5,848
xczzhh
Author by

xczzhh

Updated on September 18, 2022

Comments

  • xczzhh
    xczzhh over 1 year

    I'm trying to understand how dhcp for IPv4 is used with bridging.

    eth0 is configured to be in br0. This is working just fine but only br0 gets a dhcp lease, while eth0 doesn't. Both are configured with BOOTPROTO=dhcp. If anything, I would have expected eth0 to have the IP address and br0 as a "layer 2 device" to have none, not the other way around.

    Any suggestion would be greatly appreciated.

  • xczzhh
    xczzhh over 11 years
    Thank you for the answer. Well, now, I do agree that an IP address is needed for the bridge to connect the network. But I am not so sure what you mean by it doesn't make sense to put any L3 protocol address on port interfaces. Do you mean, in this case, the bridge interface(br0) is acting as an ethernet interface of the whole virtual machine so that there is no need for the port interface(eth0) to have an IP?
  • xczzhh
    xczzhh over 11 years
    Thank you for the answer, which makes a lot sense. But, who is the dhcp server here? the host OS?
  • midnightsteel
    midnightsteel over 11 years
    the host can be the DHCP as long as you specify it in the config. See: libvirt.org/formatnetwork.html
  • cheshirecatalyst
    cheshirecatalyst over 11 years
    You have a bridge (br0) with multiple port interfaces (eth0, eth1). What it means is that, when a packet comes in on eth0 or eth1, the Linux kernel will divert the packet to the br0 before the IP stack gets a chance to do anything with it. Only after the packet gets routed to br0 does it get handed up to IP layer, so the IP address has to be assigned to br0.