Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an Ubuntu 10.04 server with static IP address configuration:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.2.51
network 192.168.2.0
netmask 255.255.255.0
broadcast 192.168.2.255
gateway 192.168.2.1

From time to time (between once a month or once every 3 days depending on load) the server will spontaneously discard this IP address and change to one configured via DHCP.

When this happens I need to SSH into the server (using its .local hostname) and do /etc/init.d/networking restart to get it to use the static IP again.

How can this happen, and more importantly, how can I stop it?

share|improve this question
    
I would suggest you installing auditd to see 'who' made changes to the /etc/networking/interfaces. –  quanta Nov 7 '11 at 11:01
    
@quanta I made the file, but that's not the problem. The file doesn't change, just the actual IP address does. –  Bart van Heukelom Nov 7 '11 at 11:55
add comment

2 Answers

Is it possible that there is a DHCP client process still running?

Perhaps you changed the server from DHCP to static, performed a network restart but the dhclient process didn't exit correctly.

You can do

johnf@zoot:~$ ps ax | grep [d]hclient
28248 ?        S      0:00 /sbin/dhclient # Other args

to check.

If so kill this process off or reboot.

share|improve this answer
    
I can check but I'm pretty sure the server has been rebooted multiple times since it was given a static IP. –  Bart van Heukelom Dec 4 '11 at 3:37
add comment

Why not configure the DHCP server to hand out the IP address you want based on the server's MAC address? With ISC dhcpd (the de-facto standard DHCP server for unix systems) just put something like this in the config (make sure that subnet mask and gateway are already configured properly):

host server01
{
    hardware ethernet MA:CA:DD:RE:SS;
    fixed-address 192.168.2.51;
    option host-name "server01";
}
share|improve this answer
    
The server is actually in a small business network with a consumer router-modem, but it's a Linksys so maybe a static lease is possible. Still, it shouldn't be necessary. Another server in the same network is configured with a static IP the same way, and it never has problems. –  Bart van Heukelom Nov 14 '11 at 10:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.