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 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.

share|improve this question
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 7 '12 at 13:04
1  
My guess is that this won't work. The DHCP protocol en.wikipedia.org/wiki/… 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 7 '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 7 '12 at 13:57
    
I stand corrected! –  cjc Feb 7 '12 at 14:55
add comment

2 Answers

up vote 1 down vote accepted

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.

share|improve this answer
    
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 8 '12 at 10:52
add comment

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
share|improve this answer
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 7 '12 at 13:14
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.