6

I have a server running Fedora 28. I've created six connections using nmcli. I would like for these connections to be brought up in a certain order each time the system boots. How do I do this?

When I checked the NetworkManager reference manual, I noticed the connection.autoconnect-priority setting, which reads,

"The autoconnect priority. If the connection is set to autoconnect, connections with higher priority will be preferred. Defaults to 0. The higher number means higher priority."

This does not sound like the functionality I'm after. I do not want to activate one connection without activating the remaining five. I want all six connections to activate in a certain order.

I considered the idea of adding the nmcli con up command to my crontab and calling it at bootup, but I'm wondering if a more "elegant" solution exists.

4
  • 1
    If you say why do you want this, then you may get useful answers. Other than that, making connections manual and activating them with a systemd service looks like the most reasonable approach to what you describe. Commented May 17, 2018 at 20:36
  • @akostadinov, I can't speak for the original poster, but I have a rationale here: Using nm-openvswitch with a bridge with an enslaved ethernet device and a "internal" port, DHCP on the internal port fails if NM tries to bring it up before the ethernet connection is up. So I'd like to activate the bridge and enslaved physical devices first before trying to bring up the internal port. Like ADS103, I haven't found an elegant way to do that.
    – uncleremus
    Commented Jul 4, 2019 at 16:53
  • @uncleremus, are you sure this is the issue? I would assume eht interface has almost immediate wired connection when it is brought up. Is there some network device that is slower to boot? Commented Jul 5, 2019 at 18:31
  • 1
    @akostadinov, it's an e1000e device. I haven't reproduced this lately (after updating NM to 0.6.4).
    – uncleremus
    Commented Jul 8, 2019 at 11:26

2 Answers 2

1

This will bring them up one by one. Set the ONBOOT parameter to no first.

#!/bin/bash

while true
do
  ip link set eth0 up && break
  sleep 3
done

echo "eth0 up.."

while true
do
  ip link set eth1 up && break
  sleep 3
done

echo "eth1 up.."
1
#!/bin/bash
for iface in eth1 eth3 eth0 eth2 
do
  count=0
  until  ip link set $iface up || [ $((++count)) -gt 20 ] 
  do
    sleep 3
  done

  if [ $count -gt 20 ] 
  then 
    echo " FAILURE to start interface $iface .."
  else
    echo "interface $iface up.."
  fi
done

This is really just a refactoring of the code in the Maltigo's answer.
It also adds code to back off after multiple failures.

2
  • Welcome to SuperUser! Please do not only copy other answers, if you think you can improve them use the "edit" functionality. As you don't have enough reputation to single handedly edit posts, your edit will be placed in a queue to be reviewed by other community members. Commented Feb 4, 2022 at 13:57
  • I tried to submit this as an edit, and was told to do it as a new answer.
    – darkonc
    Commented Feb 7, 2022 at 0:22

You must log in to answer this question.

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