Bridge 在启动时无法通过 DHCP 获取 IP

Bridge 在启动时无法通过 DHCP 获取 IP

我正在运行 CentOS 7。我没有运行 NetworkManager,而且我实际上已经卸载了它。

我的系统应该在br0启动时通过 DHCP 获取 IPv4 地址。但是,当我登录时,它没有地址。

我的配置:

# pwd
/etc/sysconfig/network-scripts

# cat ifcfg-enp5s0 
DEVICE=enp5s0
ONBOOT="yes"
BRIDGE=br0

# cat ifcfg-br0 
DEVICE=br0
ONBOOT=yes
TYPE=Bridge
BOOTPROTO=dhcp
STP=on
DELAY=0

请注意,我没有手动配置此桥;当我在此对话框中virt-manager添加时这样做:br0

virt-manager 屏幕截图在“网络接口”选项卡上显示 br0

相关内容journalctl --boot | grep '\(\<br0\>\|enp5s0\)'和背景:

Jan 08 21:04:32 jonathon-centos7 kernel: r8169 0000:05:00.0 enp5s0: link down
Jan 08 21:04:32 jonathon-centos7 kernel: IPv6: ADDRCONF(NETDEV_UP): enp5s0: link is not ready
Jan 08 21:04:32 jonathon-centos7 kernel: r8169 0000:05:00.0 enp5s0: link down
Jan 08 21:04:32 jonathon-centos7 kernel: device enp5s0 entered promiscuous mode
Jan 08 21:04:32 jonathon-centos7 network[947]: Bringing up interface enp5s0:  [  OK  ]
...
Jan 08 21:04:32 jonathon-centos7 network[947]: Bringing up interface br0:
Jan 08 21:04:32 jonathon-centos7 kernel: IPv6: ADDRCONF(NETDEV_UP): br0: link is not ready
...
Jan 08 21:04:34 jonathon-centos7 kernel: r8169 0000:05:00.0 enp5s0: link up
Jan 08 21:04:34 jonathon-centos7 kernel: IPv6: ADDRCONF(NETDEV_CHANGE): enp5s0: link becomes ready
Jan 08 21:04:34 jonathon-centos7 kernel: br0: port 1(enp5s0) entered listening state
Jan 08 21:04:34 jonathon-centos7 kernel: br0: port 1(enp5s0) entered listening state
//// (Note: 2 second delay here, with no other events)
Jan 08 21:04:36 jonathon-centos7 avahi-daemon[957]: Registering new address record for fe80::f66d:4ff:fe3b:c24e on enp5s0.*.
Jan 08 21:04:36 jonathon-centos7 kernel: br0: port 1(enp5s0) entered learning state
///// (Too soon!)
Jan 08 21:04:38 jonathon-centos7 network[947]: Determining IP information for br0... failed; no link present.  Check cable?
Jan 08 21:04:38 jonathon-centos7 network[947]: [FAILED]
Jan 08 21:04:38 jonathon-centos7 systemd[1]: network.service: control process exited, code=exited status=1
Jan 08 21:04:38 jonathon-centos7 systemd[1]: Failed to start LSB: Bring up/down networking.
Jan 08 21:04:38 jonathon-centos7 systemd[1]: Unit network.service entered failed state.
...
Jan 08 21:04:38 jonathon-centos7 kernel: br0: topology change detected, propagating
Jan 08 21:04:38 jonathon-centos7 kernel: br0: port 1(enp5s0) entered forwarding state
Jan 08 21:04:38 jonathon-centos7 kernel: IPv6: ADDRCONF(NETDEV_CHANGE): br0: link becomes ready
Jan 08 21:04:39 jonathon-centos7 avahi-daemon[957]: Registering new address record for fe80::f66d:4ff:fe3b:c24e on br0.*.
Jan 08 21:04:41 jonathon-centos7 avahi-daemon[957]: Registering new address record for 2605:a000:1315:8119:f66d:4ff:fe3b:c24e on br0.*.
Jan 08 21:04:41 jonathon-centos7 avahi-daemon[957]: Withdrawing address record for fe80::f66d:4ff:fe3b:c24e on br0.

///// (Here's where I entered `ifup br0`)
Jan 08 22:43:30 jonathon-centos7 dhclient[5009]: DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 6 (xid=0x25f649b7)
Jan 08 22:43:31 jonathon-centos7 dhclient[5009]: DHCPREQUEST on br0 to 255.255.255.255 port 67 (xid=0x25f649b7)
Jan 08 22:43:34 jonathon-centos7 avahi-daemon[957]: Joining mDNS multicast group on interface br0.IPv4 with address 10.0.1.128.
Jan 08 22:43:34 jonathon-centos7 avahi-daemon[957]: New relevant interface br0.IPv4 for mDNS.
Jan 08 22:43:34 jonathon-centos7 avahi-daemon[957]: Registering new address record for 10.0.1.128 on br0.IPv4.
Jan 08 23:43:17 jonathon-centos7 dhclient[5124]: DHCPREQUEST on br0 to 10.0.1.1 port 67 (xid=0x25f649b7)

系统启动并登录后,我可以打开终端,然后:

# ifup br0
set forward delay failed: Numerical result out of range

Determining IP information for br0... done.

然后我就连接到我的网络了。

为什么我无法br0在启动时获取 IP?

有关的:

笔记:

  • brctl showstp br0显示转发延迟设置为 2.00。brctl setfd br0 0显示与 相同的错误ifup br0。看来 virt-manager 指定了无效DELAY=0br0.
  • 在日志中找到重要条目后,似乎正在尝试在进入转发状态之前systemd获取 IP 。br0
  • 我已经打开了错误 8086在 CentOS bugtracker 上。

答案1

你的网桥不是由网络初始化脚本控制的,而是由 libvirt 控制的。当 libvirtd 服务启动时,桥应该启动。

我不会这样跑。我将使网桥由网络初始化脚本控制,并且在 libvirt 配置中没有网桥。

您现在拥有的 ifcfg- 文件很好。只需从 libvirt 中删除配置,确保您仍然拥有这些文件,然后chkconfig network on

是的,chkconfig 适用于 EL7。

答案2

引用自http://www.microhowto.info/howto/persistently_bridge_traffic_ Between_two_or_more_ethernet_interfaces_on_redhat.html:

因此,您可能希望在简单情况下禁用 STP(例如将一组虚拟机桥接到单个物理接口时)

禁用 STP 似乎是让它工作的方法。

答案3

当您的网桥启动时,您的物理链路尚未启动。为您的物理接口添加延迟。

相关内容