我有一个具有静态IP地址configuration的Ubuntu 10.04服务器:
# 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
有时(每月一次或每三天一次,取决于负载),服务器将自发丢弃该IP地址,并更改为通过DHCPconfiguration的IP地址。
当发生这种情况时,我需要SSH到服务器(使用它的.local主机名),并执行/etc/init.d/networking restart以使其再次使用静态IP。
这怎么可能发生,更重要的是,我怎么能阻止它呢?
是否有DHCP客户端进程仍在运行?
也许你将服务器从DHCP更改为静态,执行networking重新启动,但dhclient进程没有正确退出。
你可以做
johnf@zoot:~$ ps ax | grep [d]hclient 28248 ? S 0:00 /sbin/dhclient # Other args
去检查。
如果是这样,closures或重新启动这个过程。
为什么不configurationDHCP服务器来根据服务器的MAC地址分发所需的IP地址? 使用ISC dhcpd(unix系统事实上的标准DHCP服务器),只要在configuration中join类似的东西(确保子网掩码和网关已经正确configuration):
host server01 { hardware ethernet MA:CA:DD:RE:SS; fixed-address 192.168.2.51; option host-name "server01"; }