Thursday, April 7, 2016

linux - Determine the IP address of the DHCP server from a client machine



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.


Answer



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


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...