Missing default gateway after reboot (Centos 7, Hoster Hetzner)

Issues related to configuring your network
Post Reply
mrk
Posts: 2
Joined: 2016/05/11 11:21:45

Missing default gateway after reboot (Centos 7, Hoster Hetzner)

Post by mrk » 2016/05/11 12:53:36

Hi CentOS-Buddies out there,

today my colleague and me were working on a CentOS 7.2 minial-installation in a kvm-guest. We tried several ways to get the default gateway to work. Up to now without success.
It has to be mentioned, that the KVM-Host is running an ubuntu 16.04 lts and it is hosted by hetzner. They have got some rare network-setup there. Each kvm guests gateway has to point to the hosts ip. Hetzner give customers advice to extend the guests ip-settings. The advices can be found here https://wiki.hetzner.de/index.php/Netzk ... ion_CentOS

According to these advices, the configuration of the CentOS 7 guest system looks like that.

/etc/sysconfig/network

Code: Select all

# Created by anaconda
NETWORKING=yes
#GATEWAYDEV=eth0
#GATEWAY=138.201.57.88
#SCOPE="peer 138.201.57.88"

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

Code: Select all

DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
IPADDR=138.201.144.151
NETMASK 255.255.255.255
SCOPE="peer 138.201.57.88"
GATEWAY=138.201.57.88

#DEFROUTE=yes
#TYPE=Ethernet
#NM_CONTROLLED=no
#PEERDNS=no
#SLAVE=no
#DELAY=0
#DNS1=8.8.8.8
The services NetworkManager and NetworkManager-wait-online are disabled via systemctl.

Afer booting, the routing-table is missing the default gw.

routes without default gw after reboot

Code: Select all

         target            gateway          source    proto    scope    dev tbl
  138.201.57.88                    138.201.144.151   kernel     link   eth0 
   169.254.0.0/ 16                                              link   eth0 
      127.0.0.0          broadcast       127.0.0.1   kernel     link     lo local
     127.0.0.0/ 8            local       127.0.0.1   kernel     host     lo local
      127.0.0.1              local       127.0.0.1   kernel     host     lo local
127.255.255.255          broadcast       127.0.0.1   kernel     link     lo local
138.201.144.151              local 138.201.144.151   kernel     host   eth0 local
138.201.144.151          broadcast 138.201.144.151   kernel     link   eth0 local
            ::/ 96     unreachable                                       lo 
::ffff:0.0.0.0/ 96     unreachable                                       lo 
    2002:a00::/ 24     unreachable                                       lo 
   2002:7f00::/ 24     unreachable                                       lo 
   2002:a9fe::/ 32     unreachable                                       lo 
   2002:ac10::/ 28     unreachable                                       lo 
   2002:c0a8::/ 32     unreachable                                       lo 
   2002:e000::/ 19     unreachable                                       lo 
   3ffe:ffff::/ 32     unreachable                                       lo 
        fe80::/ 64                                   kernel            eth0 
        default        unreachable                   kernel              lo unspec
            ::1              local                     none              lo local
fe80::5054:ff:fedc:9df       local                     none              lo local
        ff00::/ 8                                                      eth0 local
        default        unreachable                   kernel              lo unspec
As expected, the network is unreachable, because the default route is missing.

Code: Select all

[user@Server]ping -c 1 8.8.8.8
connect: Network is unreachable
[user@Server]

Without default gateway I am able to ping the guest from the host and to ping the host from the guest.


Adding a default gw via shell noe works well.

Code: Select all

ip route replace default via 138.201.57.88 dev eth0
routes without default gw after reboot

Code: Select all

         target            gateway          source    proto    scope    dev tbl
        default      138.201.57.88                                     eth0 
  138.201.57.88                    138.201.144.151   kernel     link   eth0 
   169.254.0.0/ 16                                              link   eth0 
      127.0.0.0          broadcast       127.0.0.1   kernel     link     lo local
     127.0.0.0/ 8            local       127.0.0.1   kernel     host     lo local
      127.0.0.1              local       127.0.0.1   kernel     host     lo local
127.255.255.255          broadcast       127.0.0.1   kernel     link     lo local
138.201.144.151              local 138.201.144.151   kernel     host   eth0 local
138.201.144.151          broadcast 138.201.144.151   kernel     link   eth0 local
            ::/ 96     unreachable                                       lo 
::ffff:0.0.0.0/ 96     unreachable                                       lo 
    2002:a00::/ 24     unreachable                                       lo 
   2002:7f00::/ 24     unreachable                                       lo 
   2002:a9fe::/ 32     unreachable                                       lo 
   2002:ac10::/ 28     unreachable                                       lo 
   2002:c0a8::/ 32     unreachable                                       lo 
   2002:e000::/ 19     unreachable                                       lo 
   3ffe:ffff::/ 32     unreachable                                       lo 
        fe80::/ 64                                   kernel            eth0 
        default        unreachable                   kernel              lo unspec
            ::1              local                     none              lo local
fe80::5054:ff:fedc:9df       local                     none              lo local
        ff00::/ 8                                                      eth0 local
        default        unreachable                   kernel              lo unspec

As expected, the network is now reachable, because the default route is present.

Code: Select all

[user@Server]ping -c 1 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=40 time=27.4 ms

--- 8.8.8.8 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 27.457/27.457/27.457/0.000 ms
After that experience I added

Code: Select all

/sbin/ip route replace default via 138.201.57.88 dev eth0
to /etc/rc.local. But after a reboot, the default gateway is missing - unless I set via bash command.

I also tried to create a routing-file /etc/sysconfig/network-scripts/route-eth0

Code: Select all

ADRESS0=0.0.0.0
NETMASK0=0.0.0.0
GATEWAY0=138.201.57.88
without success.


Do you have any idea, how to set the default gateway on boot properly? Or maybe a hint, why the default gateway isn't set.

thx in advance
Mrk
Last edited by mrk on 2016/05/17 08:20:11, edited 2 times in total.

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: Missing default gw after reboot

Post by gerald_clark » 2016/05/11 13:25:10

With a netmask of 255.255.255.255, there can be no gateway or network IP address.

giulix63
Posts: 1305
Joined: 2014/05/14 10:06:37
Location: UK

Re: Missing default gw after reboot

Post by giulix63 » 2016/05/11 13:39:47

It should look like this
/etc/sysconfig/network-scripts/route-eth0:

Code: Select all

138.201.57.88 dev eth0
default via 138.201.57.88 dev eth0
I guess the other syntax is also ok, provided -as gerald_clark already observed- you use ADDRESSn and NETMASKn directives only to specify valid static routes.
Root is evil: Do not use root (sudo) to run any of the commands specified in my posts unless explicitly indicated. Please, provide the necessary amount of context to understand your problem/question.

mrk
Posts: 2
Joined: 2016/05/11 11:21:45

Re: Missing default gw after reboot

Post by mrk » 2016/05/11 13:54:35

giulix63 wrote:It should look like this
/etc/sysconfig/network-scripts/route-eth0:

Code: Select all

138.201.57.88 dev eth0
default via 138.201.57.88 dev eth0
I guess the other syntax is also ok, provided -as gerald_clark already observed- you use ADDRESSn and NETMASKn directives only to specify valid static routes.
Right, that is the trick! Now the default-gw is set properly during the boot-sequence

@gerald clark. This ip-assignment is currently the way, Hetzner provides ips to his customers. Take a look at their sheet.

Post Reply