CentOS 7 default gateway not being set for eth0 on boot

Hi,

I have a problem with a Linode which has no IPv4 connectivity (have to use LISH to access it) after reboot. I tracked the problem down to no default gateway being set for eth0; I can manually fix it, but not sure how to do a permanent fix.

The funny thing is I am comparing all the network files/configuration to another Linode in the same datacenter; everything seems to match and one Linode works, the other doesn't…

Network Helper is on for both Linodes.

Here's what I get after I boot (IPs modified for privacy):

# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
***.***.***.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
link-local 0.0.0.0 255.255.0.0 U 0 0 0 eth0

# /sbin/route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
***.***.***.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0

ifcfg-eth0 looks good to me and is exactly the same as on the second Linode that works fine:

# cat /etc/sysconfig/network-scripts/ifcfg-eth0

# Generated by Linode Network Helper
# Fri Apr 2 10:59:56 2021 UTC
#
# This file is automatically generated on each boot with your Linode's
# current network configuration. If you need to modify this file, please
# first disable the 'Auto-configure Networking' setting within your Linode's
# configuration profile:
# - https://cloud.linode.com/linodes/xxxxxxxxxxxxxx/advanced
#
# For more information on Network Helper:
# - https://www.linode.com/docs/platform/network-helper
#
# A backup of the previous config is at /etc/sysconfig/network-scripts/.ifcfg-eth0.linode-last
# A backup of the original config is at /etc/sysconfig/network-scripts/.ifcfg-eth0.linode-orig
#
# /etc/sysconfig/network-scripts/ifcfg-eth0

# For full descriptions of what these switches do,
# and what the interface's defaults are, see
# /usr/share/doc/initscripts-*/sysconfig.txt

DEVICE="eth0"
NAME="eth0"
ONBOOT="yes"

# "bootp" and "dhcp" are for dhcp, anything else
# is for a static configuration. "none" is given
# by sysconfig.txt so we're using it.
BOOTPROTO="none"

# Use hardware-based IPv6 addresses, no privacy extensions.
IPV6INIT="yes"
IPV6_ADDR_GEN_MODE="eui64"
IPV6_PRIVACY="no"

# Since we want a static configuration, we're specifying DNS
# addresses in this file for NetworkManager. "No" here tells
# NM to use them when BOOTPROTO!=dhcp.
PEERDNS="no"

DOMAIN=members.linode.com

GATEWAY0=***.***.***.1

# resolvconf doesn't recognize more than 3 nameservers.

DNS1=96.126.124.5
DNS2=72.14.188.5
DNS3=198.58.111.5

# Sysconfig.txt says that PREFIX takes precedence over
# NETMASK when both are present. Since both aren't needed,
# we'll go with PREFIX since it seems to be preferred.

# IP assignment for eth0
IPADDR0=***.***.***.101
PREFIX0=24

When I manually add a default gateway:

# route add default gw ***.***.***.1

The connectivity is restored:

# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
default gw-li***.linode 0.0.0.0 UG 0 0 0 eth0
***.***.***.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
link-local 0.0.0.0 255.255.0.0 U 0 0 0 eth0

# /sbin/route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 ***.***.***.1 0.0.0.0 UG 0 0 0 eth0
***.***.***.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0

But back to the same problem if I reboot or:

service network restart

Any ideas what could be causing this?

I know I can manually add the gateway, but I'd like to use the Network Helper without any manual configuration.

3 Replies

Hello,

The problem is with GATEWAY0=***.***.***.1 config line, this line should look like GATEWAY=***.***.***.1 as there is no Network Helper service.

From the original ifcfg-eth0 file:

# Network Helper detected that you do not have
# NetworkManager running, let us give you a hand
# with that so you don't reboot and have no
# network access.
NM_CONTROLLED=no

# When using NM_CONTROLLED=no, we need
# GATEWAY with no integer following it.
GATEWAY=xxx.xxx.xxx.1

Pay attention to this comment:

# When using NM_CONTROLLED=no, we need
# GATEWAY with no integer following it.

Hello Marko,

Thank you, I appreciate your response!

Some comments:

  1. the ifcfg-eth0 is generated by and gets overwritten by Linode upon server reboot because I have "Auto-configure networking" enabled in this Linode's Configuration > Filesystem/Boot Helpers. I thought Linode would configure it correctly?

  2. I have this exact same setup on 3 other linodes (Centos 7.9, CPanel 94.0.4, Auto-networking enabled) in 3 different datacenters. Here's the result:

  • LINODE A: Dallas, TX = doesn't work

ifcfg-eth0 contains:
GATEWAY0
NO mention of NM_CONTROLLED

  • LINODE B: Dallas, TX = works OK

ifcfg-eth0 contains:
GATEWAY0
NO mention of NM_CONTROLLED

  • LINODE C: Frankfurt, DE = works OK

ifcfg-eth0 contains:
GATEWAY
NM_CONTROLLED="no"

  • LINODE D: Sydney, AU = works OK

ifcfg-eth0 contains:
GATEWAY
NM_CONTROLLED="no"

As you see:

  • in Dallas, ifcfg-eth0 gets auto-generated differently than in other datacenters, and

  • both Linodes in Dallas have the same ifcfg-eth0 (just different IPs of course) and one works, the other doesn't

See my confusion? :-)

P.s.: looks like I'm not alone having this problem; Linode support referenced this article in a support ticket:
https://support.cpanel.net/hc/en-us/articles/360060649894-Loss-of-Networking-on-Linode-after-Update-or-Reboot

No idea why the difference in the above 4 Linodes, doesn't make any sense.

Hey,

Apparently, they are changing Linode's Network Helper template which causing these problems on CentOS 7 after the reboot.

The problem is why "Network Helper detected that you do not have NetworkManager running" doesn't seem to detect that there is no NetworkManager on the server, and we are running a clean CentOS 7 template provided by Linode.

Currently, all you can do is disable Linode's Network Helper and manually edit ifcfg-eth0 file, but this is not a permanent solution.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct