Thoughts Electrique

Posts Tagged ‘CentOS’

Static IPs and default route on 1und1 CentOS 5 Servers

Wednesday, March 11th, 2009

I’ve been experiencing some serverdowns at a client who uses 1und1 CentOS 5 Servers. After some investigation I discovered that cronjobs were still running although the server appeared to be down. Checking the syslogs showed me a bunch of failed DHCP requests which remebered me of the fact that 1und1 uses DHCP to configure the server machines. I don’t think this is a good idea so I changed the setup to static IPs.

Since 1und1 puts every server behind a dedicated firewall the setup is not as easy as you think. I’ll document it here because It may be useful for other people and certainly for myself after a couple of months.

Configure a static IP address

Open the file /etc/sysconfig/network-scripts/ifcfg-eth0 and edit it to look like the following:

DEVICE=eth0
BOOTPROTO=none
TYPE=Ethernet
ONBOOT=yes
HWADDR=$YOURMACADDRESS
NETMASK=255.255.255.255
IPADDR=$YOURIP
GATEWAY=10.255.255.1

Save the file.

Configure static routes

This is the tricky part. Configuring a default gateway using the GATEWAY= setting is not enough. You have to setup the routes yourself. To do so create a new file /etc/sysconfig/network-scripts/route-eth0 with the following contents:

10.255.255.1 dev eth0
default via 10.255.255.1 dev eth0

Now you only have to reload the networking configuration via

service network reload

and you are done!

This post helped me a lot with the solution.