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 know what is the best way to get the DHCP server address from a client (linux based), who just got an IP address from the DHCP server?

I searched and found this in most of the articles,

less /var/lib/dhcp3/dhclient.leases

But say, the client is a Virtual machine and was assigned an IP address from some external DHCP server, then the file '/var/lib/dhcp3/dhclient.leases' won't be present.

I've tried doing a 'ifconfig' in the client machine and this was the output

eth0      Link encap:Ethernet  HWaddr 00:0C:29:2C:3C:6A  
          inet addr:192.168.163.128  Bcast:192.168.163.255  Mask:255.255.255.0

I can see the BroadCast(Bcast) address but cannot find anywhere the real DHCP server address.

Hope somebody could provide me a good solution.

Thanks and best regards.

share|improve this question
1  
Why do you believe dhclient.leases would not be present? That doesn't make sense. DHCP needs to store its state somewhere, and that is the place it is stored. Why would being a virtual machine make one bit of difference. The point of a VM is that the OS acts exactly like it would act on physical hardware. –  Zoredache Jul 17 '12 at 16:25
    
Sorry to reply late. I was buried in some work. Yeah, I confirmed. When I got IP addresses from the external DHCP for my VM, say, when I'm in NAT mode in VMware, the dhclient.leases file wan't present. I don't know what might have happened. –  SSaikia_JtheRocker Jul 27 '12 at 19:12

1 Answer 1

up vote 3 down vote accepted

Type dhclient -v In the out put search for DHCPACK. It has the IP of the dhcp server

share|improve this answer
    
I tried dhclient -v, it says "dhclient(31917) is already running - exiting." –  SSaikia_JtheRocker Jul 17 '12 at 10:20
1  
Try grep -r "DHCPOFFER" /var/log/* it will give you the dhcp server if you cannot run dhclient. –  Manula Waidyanatha Jul 17 '12 at 10:37

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.