5

I have a headless Centos server that I've configured with a static IP address. I've disabled Network Manager, avahi-daemon etc. Whenever I restart the network it just jumps to 10.155.90.100 instead of the required 10.155.90.61 with no explanation:

Here is my ifcfg-eth0:

   # Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
    DEVICE=eth0
    BOOTPROTO=static
    ONBOOT=yes
    #HWADDR=00:50:56:b0:5a:57
    IPADDR=10.155.90.61
    NETMASK=255.255.255.0
    GATEWAY=10.155.90.1
    TYPE=Ethernet
    USERCTL=no
    IPV6INIT=no
    PEERDNS=yes
    NM_CONTROLLED=no

It seems to be running DHCP anyway. I cant seem to get a more detailed log than this in /var/log/messges:

Jul 11 12:50:33 NET[4767]: /sbin/dhclient-script : updated /etc/resolv.conf
Jul 11 12:50:34 kernel: 8021q: adding VLAN 0 to HW filter on device eth0
Jul 11 12:50:34 kernel: ADDRCONF(NETDEV_UP): eth0: link is not ready
Jul 11 12:50:34 kernel: e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
Jul 11 12:50:34 kernel: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
Jul 11 12:50:36 dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67 (xid=0x39edae98)
Jul 11 12:50:36 dhclient: DHCPACK from 10.155.50.20 (xid=0x39edae98)
Jul 11 12:50:36 NET[5157]: /sbin/dhclient-script : updated /etc/resolv.conf
Jul 11 12:50:36 dhclient: bound to 10.155.90.100 -- renewal in 255205 seconds.

How can I turn off DHCP and stop the server jumping for the wrong IP?

4
  • 2
    deinstall the service? dhclient Jul 11, 2014 at 12:22
  • 1
    What other files do you have by way of /etc/sysconfig/network-scripts/ifcfg-eth*? Anything that might be starting dhclient there? Or perhaps something hand-hacked in /etc/rc.d/rc.local?
    – MadHatter
    Jul 11, 2014 at 12:25
  • @DennisNolte. That fixed it!
    – blarg
    Jul 11, 2014 at 14:07
  • @blarg added an answer. however the other answers are worth reading aswell. Jul 11, 2014 at 14:09

4 Answers 4

3

plain and simple solution: deinstall what you dont need :)

yum remove dhclient 
2
  • Or just stop the service.
    – ewwhite
    Jul 11, 2014 at 18:12
  • It will fix this problem but it's a bit "brute force". What if other interfaces need DHCP? I would investigate Nathan C's answer below about PEERDNS.
    – Andrew
    Jul 11, 2014 at 18:46
7

You don't need PEERDNS since you're using a static IP. This is causing dhclient to run and update your resolv.conf file (as it's designed to do). In the process, it also requests an IP address when it requests the nameservers from DHCP.

2

To assign a fixed IP address, use none as the value for BOOTPROTO.

From the "RHEL5 Deployment Guide", section "Interface Configuration Files":

BOOTPROTO=protocol

where protocol is one of the following:

  • none — No boot-time protocol should be used.
  • bootp — The BOOTP protocol should be used.
  • dhcp — The DHCP protocol should be used.
3
  • I don't think that's right; I use BOOTPROTO=static very happily in all sorts of CentOS boxes, specifically both C5 and C6, with no problems.
    – MadHatter
    Jul 11, 2014 at 12:27
  • 1
    Maybe he should have a look at the documentation i.e. less /usr/share/doc/initscripts-*/sysconfig.txt and search for BOOTPROTO. It says BOOTPROTO=none|bootp|dhcp on Scientific Linux 6.5. Jul 11, 2014 at 12:49
  • It appears none or static is dependent on the OS. RHEL5 changed it, but from the research I've done (like this wiki) CentOS still uses static.
    – Nathan C
    Jul 11, 2014 at 14:05
1

Maybe I'm a hack, but I like using the system-config-network-tui utility on RHEL/CentOS/RPM-based system for this, as it helps clean up any funky or hand-(mis)configured interface scripts.

You must log in to answer this question.

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