CentOS7 Network Bridge Fails on boot until cable unplugged and plugged back in

bridgecentos7linux-networkingnetworking

I have a problem with a brand new CentOS 7 server I am trying to set-up. I have set-up a network bridge as per instructions on the redhat documentation website and it all works great until I reboot. After rebooting it just doesn't work and I need to unplug the cable and then plug it back in and about 15 seconds later everything works. It is plugged into a simple 5 port switch if that helps and I have tried setting STP=no in both config files to no avail.

Here is my messages log [messages][2] that shows the network interface failing to start up.

My config files for br0:

DEVICE=br0
TYPE=Bridge
IPADDR=192.168.1.1
PREFIX=24
BOOTPROTO=none
ONBOOT=yes
DELAY=0

My config for the network interface (enp0s25)

DEVICE=ethX
TYPE=Ethernet
HWADDR=d0:50:**:**:**:**
BOOTPROTO=none
ONBOOT=yes
BRIDGE=br0

I have asked this question on the CentOS7 forums but haven't had much luck. Any help or guidance much appreciated.

Best Answer

I have found a workaround, not ideal but it works. Basically after the system boots run a script that brings the network interface down and then back up again.

Here is the script:

#!/bin/bash
ifdown enp0s25
sleep 3
ifup enp0s25

I then created a systemd service and a timer to accomplish the rest, I use a timer to run the service 45 seconds after the system boots. I reckon I could go down to 25 seconds but boot time is not important to me and I want to wait for the interface to be brought up naturally with takes about 15 seconds itself.

The service, called internet.service:

[Unit]
Description=Actually enable the Network Interfaces
Wants=network-online.target
After=network-online.target

[Service]
Type=oneshot
User=root
ExecStart=-/bin/bash /media/data1/MyScripts/network.sh

[Install]
WantedBy=multi-user.target

The timer, called internet.timer:

[Unit]
Description=Runs the script on boot

[Timer]
#Time to wait after boot before activating
OnBootSec=45
Unit=internet.service

[Install]
WantedBy=multi-user.target

Then all that needs to be done is setting the timer to be enabled systemctl enable internet.timer

Then when my system boots after the 45 seconds I get a nice br0: port(enp0s25) entered forwarding state message on the console which lets me know everything is working as it should be.

As I said initially, not an ideal solution but it works

Related Topic