i am having virtual server from Hetzner and after installing the CentOS 6 linux, i do not know how to make the default installation available from the internet, how to setup the routing. The Hetzner says that the gateway IP should be (https://wiki.hetzner.de/index.php/CloudServer/en#What_are_Routes.3F - "The special private IP Address This IP address is being used as a default gateway of your servers public network interface. ")

At first following worked: /sbin/route add default gw eth0

but now one day later it says SDIOCADDRT: Network is unreachable. Current routing table (route -n) contains only one rule: dev eth0 scope link metric 1002

Config file for the eth0 interface is: https://i.postimg.cc/9Qc6VwK7/ifcfg-eth0.gif

Please can you tell me which commands should make the routing table be done properly? Or what is wrong in my eth0 interface config. file?

UPDATE: i was told i should use static configuration on CentOS 6, but i am having problem with the route-eth0 file as i am unable to create it:

cp /etc/host.conf /etc/sysconfig/network-scripts/route-eth0 perl -pi -e s/multi on/172\.31\.1\.1\/32 dev eth0\\ndefault via 172\.31\.1\.1 dev eth0/g /etc/sysconfig/network-scripts/route-eth0

The error is: Substitution pattern not terminated at -e line 1.

(i can not use echo or tee or vim because Hetzner console do not work with | " ' $ > characters and Ctrl key)

  • It's best to avoid posting images if possible, but if you must do, then please upload images here. Many readers will not be able to visit external image hosting sites as they will be blocked at their workplace. Sep 24, 2019 at 12:43
  • i was told i should use static configuration on CentOS 6: wiki.hetzner.de/index.php/Cloud_IP_static/en#Fedora_.2F_CentOS
    – 16851556
    Sep 24, 2019 at 14:52
  • Link-local IP addresses ( for IPv4 and fe80::/10 for IPv6) are, by definition, not forwardable (routable). Also, a gateway needs to be in the same network as the host address, otherwise you would need a gateway to reach the gateway.
    – Ron Maupin
    Sep 24, 2019 at 15:11

1 Answer 1


They told me i need to use static configuration and it worked (after restarting network / rebooting).

(Note that the IPs under that link are likely specific only to a Hetzner servers)

Adjusting the configuration files was very difficult via Hetzner console (which does not accept Ctrl key, | > $ " ' etc.).

These were the commands i had to run (will almost certainly work only on Hetzner + CentOS 6 and after replacing myvpspubliciphere. But can give idea for anyone using limitted web console like one from Hetzner):

perl -pi -e s/BOOTPROTO=dhcp/BOOTPROTO=static/g /etc/sysconfig/network-scripts/ifcfg-eth0
perl -pi -e s/IPV6INIT=no/IPADDR=myvpspubliciphere/g /etc/sysconfig/network-scripts/ifcfg-eth0
perl -pi -e s/ONBOOT=yes/ONBOOT=yes\\nNETMASK=\\nDNS1=\\nDNS2= /etc/sysconfig/network-scripts/ifcfg-eth0
cp /etc/host.conf /etc/sysconfig/network-scripts/route-eth0
perl -pi -e s/multi\ on/\\/32\ dev\ eth0\\ndefault\ via\\ dev\ eth0/g /etc/sysconfig/network-scripts/route-eth0
service network restart

(the cp command was used to get a small file with just a two words which i can use for easily replacing its content by what i needed)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .