4

I would like to shorten the bootup time of my CentOS Virtual Machines. They are spawn up automatically during our test cycle. We noticed that it could take up to 15 seconds to obtain an IP address from the DHCP server, and suspect it has to do with the DHCP broadcast discovery.

How do I hardcode the ip address of the DHCP server in CentOS 5.3 ?

[edit] I noticed that the dhclient man page has the "-s" options which allows to specify the exact DHCP IP address. However that does not affect the boot cycle of the VM.

Itai Frenkel
  • 203
  • 1
  • 8
  • 2
    I take it you mean that you want to send a directed DHCP request to a specific IP address rather than broadcast, but you still want the DHCP server to send the IP config details to the client. That is an interesting question. – dunxd Feb 07 '12 at 13:04
  • 1
    My guess is that this won't work. The DHCP protocol http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol#DHCP_discovery specifies a UDP packet sent to the broadcast address. What the OP is asking for sounds like a chicken-and-egg problem using information about the LAN before actually receiving information about the LAN. It might be better to figure out why DHCP broadcast isn't working quickly through the host machine. – cjc Feb 07 '12 at 13:21
  • 1
    cjc, I just edited the question to reference the dhclient man page which shows there is an option to specify the dhcp server ip adddress (-s) – Itai Frenkel Feb 07 '12 at 13:57
  • I stand corrected! – cjc Feb 07 '12 at 14:55

2 Answers2

1

Now that I've found out something about dhclient options, I took a look at /etc/sysconfig/network-scripts/ifup-eth. In the very worst case, you can edit that script to run dhclient with the -s option to specify the DHCP server.

There's also an optional /etc/dhclient.conf file, but looking at man dhclient.conf I don't see any option that corresponds to the "-s" command line switch.

cjc
  • 24,916
  • 3
  • 51
  • 70
  • I've added the following lines in the ifup-eth file and indeed it affected the boot sequence. We are now troubleshooting the DHCP issues themselves. DHCLIENTARGS="-s 192.168.10.12" – Itai Frenkel Feb 08 '12 at 10:52
-1

For hardcode your IP address. I prefer to configure it static.

vim /etc/sysconfig/network-scripts/ifcfg-eth0 <interface-name> For each network interface, there is a corresponding interface configuration script. Each of these files provide information specific to a particular network interface

Add following

DEVICE=eth0 
BOOTPROTO=none 
ONBOOT=yes 
NETWORK=10.0.1.0 
NETMASK=255.255.255.0 
IPADDR=10.0.1.27 
GATEWAY=10.0.1.1
sysadmin1138
  • 133,124
  • 18
  • 176
  • 300
user103373
  • 198
  • 6
  • 19
  • 1
    This isn't what the OP asked for. Also, it won't work in the OP's implied scenario, where he's booting up a bunch of VMs based on the same basic iamge. In that case, a static IP in the image will cause bad things to happen. – cjc Feb 07 '12 at 13:14