Auto-connect to ethernet doesn't work

Issues related to configuring your network
Post Reply
Posts: 2
Joined: 2019/06/07 14:47:57

Auto-connect to ethernet doesn't work

Post by dekko » 2019/06/07 14:55:22


I have a server with 2 ethernet connection. One used for internet access (not the one of concern here),em1. I also have em2 which is used to talk to a hardware driver through ethernet.

I need that to always be on, and in case where it isn't I need that to reconnect. So i have a bash script who's job it is to monitor that. I check through ip route show that em2 is connect. That works fine.

When ip route tells me em2 is off, then.... Well I haven't found a way to emulate through terminal the same command that happens if I click on the network manager (in the GUI), select 'em2' and then click 'Connect' (which is what my script is supposed to do, ideally). So I have setup autoconnect on em2 and I'm thinking I can just shut down the interface & up again with:

ip link set down em2
ip link set up em2

This works fine as long as the drive was connected before it was shut down. So it's kinda useless.

Yes, I have used nmtui to set it up to auto-connect. And yes, grep ONBOOT /etc/sysconfig/network-scripts/ifcfg-* tells me everything (even non-relevent connections) are ONBOOT='yes'.

So basically I need either a way to make auto-connect actually work, or a command to do the equivalent of em2 ---­> Connect.


User avatar
Forum Moderator
Posts: 26582
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Auto-connect to ethernet doesn't work

Post by TrevorH » 2019/06/07 15:10:14

If you are using NetworkManager then it ought to just reconnect automatically.

When it's NOT working, what is the output from systemctl -l status NetworkManager network

Does nmcli conn up $interfaqce help? Or ifup $interface?
CentOS 5 died in March 2017 - migrate NOW!
CentOS 6 goes EOL sooner rather than later, get upgrading!
Full time Geek, part time moderator. Use the FAQ Luke

Posts: 2
Joined: 2019/06/07 14:47:57

Re: Auto-connect to ethernet doesn't work

Post by dekko » 2019/06/07 15:38:25


nmcli conn up $interfaqce

Is exactly what I need. If the connection is down for whatever reason, this reconnects it. Exactly the behavior I need.

I'm not sure why the auto-connect didn't work - it may be because it's not a dhcp connection but a static one (hardware reason on the other drive make it a constraint).

At any rate, you command works - thanks a bunch. You wouldn't believe how much I search for that on forums (but all I came up with was more along the lines of ip link set & equivalent). Not sure if I just had the wrong keyword or what - thanks anyways.

Post Reply

Return to “CentOS 7 - Networking Support”