How to find out if Ubuntu is using DHCP (Ubuntu 12.04 LTS GUI)

Right click on the Network Manager icon on Ubuntu top panel and select edit. Go to Wired Network or Wireless Network tab and select the network name. Click on the edit button and go to IPv4 settings tab on the new window. If the method is Automatic (DHCP) you are using dhcp.

Other method is cat /var/log/syslog and check for some thing like below

DHCPDISCOVER on eth0 to port 67 interval 6
DHCPREQUEST on eth0 to port 67

If you have some thing similar to above. You are using DHCP (IP addresses could be different)

I'm using debian but directories should be the same or similar. Check if you have the directory /var/lib/dhcp. Then:

ls -lrt /var/lib/dhcp/

You should see files named /var/lib/dhcp/ Look for the most recent file associated with the interface you're interested in and open it up:

cat /var/lib/dhcp/

The output should be something like this:

lease {
  interface "eth1";
  rebind 4 2012/08/02 03:56:17;
  expire 4 2012/08/02 04:41:17;

If /var/lib/dhcp directory doesn't exist or if it is empty, you're most likely not getting your IPs from DHCP.

A pedantic note on an old post: the contents of /etc/network/interfaces will tell you how the interfaces MAY have been managed at boot (or after running service networking restart). It is not definitive. It does not tell you how a given interface was assigned at any given moment. For example, given a DHCP managed interface I can easily kill dhclient and use ifconfig to statically assign any IP I want to an interface (I can assign an IP address in the HCHP managed range just to cause more confusion).

Maybe another admin did this to test something and forgot to clean up. Or I can run dhclient eth0 on an interface with a static assignment now DHCP will manage the interface. Or another admin maybe have made a typo and now avahi has dynamically configured the interface with a link-local address.

Sure, these things don't happen every day, but it's only under development conditions or in weird situations where I have ever asked myself, "Just how did this interface get configured?" Under normal circumstances I never find myself asking this question.

In general, I believe the answer is "No, you can't know for sure." The kernel does not maintain a record, as far as know. The best you can do is to grep through the usual suspects in /var/log/. But if someone came in an manually assigned a static IP address then you're out of luck.