Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have Ubuntu server 12.10 as DRBL and CloneZilla. How can I find out how many IP addresses have been assigned to the clients. How do I control/monitor the DHCP daemon service(stop/start/status)?

share|improve this question

To monitor Dhcp leases just type in terminal :

gedit /var/lib/dhcp/dhcpd.leases 
share|improve this answer
2  
Is gedit really the best way to peek into that file? First, it requires a desktop environment, which is usually not present on a server installation. Second: launching an editor suggests this file could be modified, but I'm pretty sure that editing it can cause nothing but trouble. – Rafał Cieślak Dec 10 '14 at 18:50
    
This is sometimes on /var/lib/NetworkManager/*.lease – CMCDragonkai Jul 1 at 13:27

The script used to control the DHCP daemon depends on which one you're using. I'm assuming isc-dhcp-server. Then it would be:

service isc-dhcp-server stop
service isc-dhcp-server start
service isc-dhcp-server status

If that doesn't work, look in /etc/init for a config file named after dhcp, and use that. Say your config file is called dhcpd3.conf, then you'd replace isc-dhcp-server in the above commands with dhcpd3.

To see "how many ip addresses have been assigned to clients", which was your original request, you can do this:

grep "^lease" /var/lib/isc-dhcp-server/dhcpd.leases |sort |uniq |wc -l

This will plainly give you the number of assigned addresses.

Again, if you get an error about /var/lib/isc-dhcp-server not being findable, look in /var/lib and replace it with something suggestind a dhcp server, usually dhcp or dhcp3

Note that as mentioned in another answer, this will miss the distinction between assigned and active (i.e. with a system using them at the moment) addresses. Also, if a client is forcefully shutdown and doesn't release the lease, you will also get unused addresses reported as assigned.

share|improve this answer

To list all the active Clients IP's you can use namp.It can list you both DHCP and as well as static clients also.

you can install namp in your PC with

sudo apt-get install nmap

Then to list all the active clients you can do like ,

 nmap -v -sP 192.168.0.0/255

here the IP's from 0 to 255 will be scanned and active IP's will be showup.

The better network monitor I can found my self is nethogs. you can get it by installing with

sudo apt-get install nethogs

Then simply

sudo nethogs <connection_name>

Can show the traffic monitor in your terminal.

hope this can help you.

share|improve this answer
2  
Big difference between assigned and active though, this will miss a lot of the inactive ones – Meer Borg Mar 8 '13 at 14:51

If you are using isc-dhcp-server on UBUNTU 14.04 headless server

To control the isc-dhcp-server

service isc-dhcp-server stop
service isc-dhcp-server start
service isc-dhcp-server status

To monitor the isc-dhcp-server

This method will work on a headless server (non-GUI) for "assigned DHCP leases only", login, enter the following command from the terminal

cat /var/lib/dhcp/dhcpd.leases

If NMAP has been installed enter this command from the terminal

nmap -v -sP 192.168.0.0/24

This method will work on this subnet and scan 256 addressees, and output IP and MAC addresses. This will respond if the HOST is down with an IP Address that has no assignment and will respond with MAC and IP Address if the HOST is up.

Depending on if a switch or router is between the PC and the network, and depending what "network layer 2/3/4" router or switch operates at.

tail -f /var/log/syslog will output DHCP addresses being actively assigned.

tcpdump -i eth0 port 67 or port 68 -e -n will capture DHCP packets on port 67 and port 68 on network interface eth0

If DHCPDUMP has been installed enter this command from the terminal

dhcpdump -i eth0 will DUMP "as it implies" DHCP information from the server to the client.

share|improve this answer

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.