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
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
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
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
Code: Select all
/sbin/ip route replace default via 138.201.57.88 dev eth0
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
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