Page 1 of 1

Default gateway/route seems to not be set by route-eth0

Posted: 2020/11/03 01:28:07
by tonyotonio
Hello All,


I currently have CentOS 7.8 minimal-installation and currently am having a peculiar network issue. And I'm quite lost on how to fix this.
ip address seems to be set just fine, but default route seems to not be set.
(perhaps I need to set a slight delay for eth0 to be fully up before setting routes?? - just a guess)


This is how my CentOS7 network config looks like:

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

Code: Select all

DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
NM_CONTROLLED=no

IPADDR=45.4.157.74
PREFIX=29
GATEWAY=85.99.10.135

DNS1=1.1.1.1
DNS2=8.8.4.4
ZONE=public
/etc/sysconfig/network-scripts/route-eth0:

Code: Select all

85.99.10.135 dev eth0
default via 85.99.10.135 dev eth0


When I do a network restart, ip seems to be set fine

Code: Select all

[user@server100 ~]# /etc/init.d/network restart
Restarting network (via systemctl):                        [  OK  ]
[user@server100 ~]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 45.4.157.74  netmask 255.255.255.248  broadcast 45.4.157.79
        ether 0a:ad:25:f4:a8:d2  txqueuelen 1000  (Ethernet)
        RX packets 152029  bytes 97195167 (92.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 159027  bytes 208549780 (198.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[user@server100 ~]#

But it seems the network is unreachable.

Code: Select all

[user@server100 ~]# ping -c 1 8.8.8.8
connect: Network is unreachable
[user@server100 ~]#
Looking at routes, default route seems to be missing

Code: Select all

[user@server100 ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask		Flags  Metric Ref	Use Iface
45.4.157.72     0.0.0.0         255.255.255.248 	U       0         0		   0   eth0
169.254.0.0     0.0.0.0         255.255.0.0     	U       1002    0             0   eth0
Looking at the message logs it show this error

Code: Select all

[user@server100 ~]# cat /var/log/messages | grep eth0
Bringing up interface eth0:  Cannot find device "eth0#015"
Nov  3 08:42:16 server100 network: Shutting down interface eth0:  [  OK  ]
Nov  3 08:42:20 server100 network: Bringing up interface eth0:  Cannot find device "eth0#015"
Nov  3 08:42:20 server100 network: Cannot find device "eth0#015"
I tried manually starting ifup-routes

Code: Select all

[user@server100 ~]# /etc/sysconfig/network-scripts/ifup-routes eth0
"annot find device "eth0
"annot find device "eth0

What's peculiar is Adding a default gw manually via cli seems to fix this:

Code: Select all

[user@server100 ~]# ip route add  85.99.10.135  dev eth0
[user@server100 ~]# ip route add default via 85.99.10.135 dev eth0

Code: Select all

[user@server100 ~]# ping -c 2 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=118 time=5.27 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=118 time=5.40 ms

--- 8.8.8.8 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 5.273/5.337/5.402/0.097 ms
[user@server100 ~]#

Re: Default gateway/route seems to not be set by route-eth0

Posted: 2020/11/03 07:13:43
by jlehtone
1. One does not set default route in *-route files. The ifup scripts take it from the GATEWAY
2. One should set GATEWAY in /etc/sysconfig/network, not in the ifcfg-*, because There can be only one!

3. Your link-local subnet is:

Code: Select all

$ ipcalc -n -b -p 45.4.157.74 255.255.255.248
PREFIX=29
BROADCAST=45.4.157.79
NETWORK=45.4.157.72
In other words, it is clear that
IF destination is in 45.4.157.72-45.4.157.79 THEN eth0 has a direct link to it.

However, 85.99.10.135 is not one of those. What is the route to 85.99.10.135?
Ok, your config says that it is link-local too. Why it is not a member of 45.4.157.72/29?
When you send to 85.99.10.135, what is the source address?
How does the 85.99.10.135 know to send replies to 45.4.157.74?

The ifup-scripts call the same 'ip' as you do. What if the script does a sanity check?


PS. The format of output of 'ip ro' (ip route show) is nice, because it has same syntax as 'ip ro ad' does use.

Re: Default gateway/route seems to not be set by route-eth0

Posted: 2020/11/03 12:48:00
by tonyotonio
jlehtone wrote:
2020/11/03 07:13:43
1. One does not set default route in *-route files. The ifup scripts take it from the GATEWAY
2. One should set GATEWAY in /etc/sysconfig/network, not in the ifcfg-*, because There can be only one!
3. Your link-local subnet is:

Code: Select all

$ ipcalc -n -b -p 45.4.157.74 255.255.255.248
PREFIX=29
BROADCAST=45.4.157.79
NETWORK=45.4.157.72
In other words, it is clear that
IF destination is in 45.4.157.72-45.4.157.79 THEN eth0 has a direct link to it.

However, 85.99.10.135 is not one of those. What is the route to 85.99.10.135?
Ok, your config says that it is link-local too. Why it is not a member of 45.4.157.72/29?
When you send to 85.99.10.135, what is the source address?
How does the 85.99.10.135 know to send replies to 45.4.157.74?

The ifup-scripts call the same 'ip' as you do. What if the script does a sanity check?
Thank you for taking time to reply sir!


Tried placing gateway in /etc/sysconfig/network, still no go.

I have similar setup to this, viewtopic.php?t=57758
And based using route-eth0 off that fix. But it doesnt seem to work for me :(

Yes this was a mistake, subnet for 45.4.157.74 should've been /32 or 255.255.255.255
Forwarding and route has also been setup at 85.99.10.135

Right now, kinda fixed it by adding the the routes in /etc/rc.d/rc.local, but it seems a bit hacky.