No Ethernet Connection at Startup - How to Create a Startup Script?

I’m noticing that my server, when it reboots, has no ethernet connection despite claiming that it does. If I manually stop and restart the connection, it’s fine. Without getting into the whys and wherefores (unless any of you know what’s happening) I thought I’d make a startup script to stop and restart the connection. Seems the following command ought to work:

$ sudo sleep 10 && service network restart

What I’m not clear on is how to execute a script that requires root privileges. What’s the best method? Thanks. :slight_smile:

EDIT: Also, maybe it’s better to stop and restart the ethernet connection rather than network manager? Haven’t found how to do that yet…

EDIT: I just tried a crontab script as root. The script ran but restarting the network manager didn’t work. What I have to do is restart the ethernet connection itself. I’m having a hard time finding that online. All my hits are for restarting the network manager. Can’t find the right search terms…

Try

man nmcli
1 Like

When you want the network started at boot (and not at user login) and using NetworkManager, you should configure as “system connection” in NW.

Or use Wicked (or systemd-network).

1 Like

Hey. That seems to be working, but it’s interesting. So, experimentally I used the command:

ip link set eno1 down

That turned off my ethernet connection. Couldn’t ping google. Then I used the same command:

ip link set eno1 up

But that didn’t work. Even though ethernet showed as up, I still couldn’t ping google. Then tried:

nmcli dev connect eno1

And that worked. Not sure what’s going on here, but am going to try that as a crontab script…

Well, “pinging Google” is not really a symptom of an up/down network

Is the NIC up and has a correct (either the fixed one you configured ot on from DHCP that fits the subnet) IP address?

ip addr

Can you connect to another system on your LAN?

ping -c1 <IP-address of your router>

(I hope you know that address)

Do you have a default route to the Internet?

ip route

and/or

ip -6 route

Can you connect to a system on the internet?

ping -c1 195.135.221.161

and/or

ping -c1 2001:67c:2178:8::161

Can you resolve host/domain names?

ping -c1 forums.opensuse.org

Only the last stpe is comparable with your “pinging Google”.

1 Like

Well… none of that worked. The only way to successfully “reset” the network connection is to go to gnome panel, choose Network—>Turn Off- and then Wired1 to restart. None of the command lines work. Not sure why or what the difference is?

That is not a satisfying reply. One does not say “none of the command lines work”. One always shows by copy/paste the prompt command line, the complete output and the new prompt line. It is the only way to show people here what you saw.

As an example. this is from one of my systems:

henk@boven:~> ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether ec:8e:b5:da:0d:0d brd ff:ff:ff:ff:ff:ff
    altname enp1s0
    inet 10.0.0.154/24 brd 10.0.0.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 2a02:a465:d34e:1:ee8e:b5ff:feda:d0d/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 6756sec preferred_lft 3156sec
    inet6 fe80::ee8e:b5ff:feda:d0d/64 scope link 
       valid_lft forever preferred_lft forever
henk@boven:~>
1 Like

Yeah, apologies. I did solve the problem though; after the right combination of search terms. Seems that, at some point, I had made my wired connection “available to other users”. Must have been me? I don’t remember doing so but how else did it happen? In Gnome, I deleted the Network “profile”, just to reset with a clean slate, and then made sure that “available to others” was unchecked and DHCP was set to automatic. This tip came from here:

(When issuing the command ip a, I noticed that my IP was set at 10.42.0.1.) It all works correctly now.

Oh, and sorry hcvv, I wasn’t replying to you when I wrote that “none of that worked” but to “susejinky”. I hadn’t seen your post yet. But thank you.