Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

How can I find out if my IP address is DHCP, Fixed or Dynamic?

I need to tell my network administrator what the IP address is, that my Virtual Machine is using. I know the numbers, but I don't know if it is fixed or not.

I have tried: ifconfig and that returned my IP address.

share|improve this question
    
A network administrator should know from the raw IP address whether it's dynamic or static. (Or at least, be able to guess with high certainty.) DHCP should always be using a dedicated pool of addresses, and static IP'd machines must never use an address in that pool, else they risk an IP collision. If you need a static address within the DHCP pool, many DHCP servers offer a way to assign a fixed value based on DHCP client ID or MAC address, but that's still DHCP. –  Warren Young Aug 30 '12 at 17:08
    
Thank you @WarrenYoung, but the network admin has a full list of all the IP addresses I have used, so there won't be any collisions. –  Kevdog777 Aug 31 '12 at 8:54

4 Answers 4

up vote 12 down vote accepted

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 255.255.255.255 port 67 interval 6
DHCPOFFER from 10.100.1.254
DHCPREQUEST on eth0 to 255.255.255.255 port 67
DHCPACK from 10.100.1.254

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

share|improve this answer
    
Thank you, my colleague just showed me this, before you gave the answer. "Word for word"! –  Kevdog777 Jul 31 '12 at 12:50

Use command:

cat /etc/network/interfaces

It will show you all interfaces and which one of them are using dhcp.

Whether dhcp is fixed or dynamic you must check on your Virtual Machine configuration. If you are using VM Ware then under edit you got Virtual Networking properties. There you will be able to check if for particular virtual interface you got dhcp reservations for specific machines. If you did not checked it yet then we can assume you did not changed default configuration which is dynamic. You can setup reservation if you wish.

Details of NAT configuration in VM Ware environment: click.

If bridged connection:

f you use bridged networking, your virtual machine needs to have its own identity on the network. For example, on a TCP/IP network, the virtual machine needs its own IP address. Your network administrator can tell you whether IP addresses are available for your virtual machine and what networking settings you should use in the guest operating system. Generally, your guest operating system may acquire an IP address and other network details automatically from a DHCP server, or you may need to set the IP address and other details manually in the guest operating system.

If you use bridged networking, the virtual machine is a full participant in the network. It has access to other machines on the network and can be contacted by other machines on the network as if it were a physical computer on the network.


Be aware that if the host computer is set up to boot multiple operating systems and you run one or more of them in virtual machines, you need to configure each operating system with a unique network address. People who boot multiple operating systems often assign all systems the same address, since they assume only one operating system will be running at a time. If you use one or more of the operating systems in a virtual machine, this assumption is no longer true.

share|improve this answer
5  
That probably won't work on Ubuntu which usually uses NetworkManager and not /etc/network/interfaces. –  scai Jul 31 '12 at 12:22
    
I use Backtrack which is based on Ubuntu. If the path is different it will probably be very similar. –  mnmnc Jul 31 '12 at 12:23
    
Yeah that didn't work, it says (with and without using sudo): auto lo iface lo inet loopback - unless it has worked, but I don't understand what was just written there. –  Kevdog777 Jul 31 '12 at 12:25
2  
It did work. You do not have an IP address for eth0. Check in Virtual Machine configuration what type of network did you choose upon Virtual Machine creation. You might have selected option "host only" but you should have used 'NAT'. –  mnmnc Jul 31 '12 at 12:28
3  
/etc/network/interfaces is the “manual” way of configuring network interfaces. Backtrack is a distribution for playing with network configurations, so it unsurprisingly favors the manual way. Ubuntu is a distribution intended to be configured automatically by preference and through the GUI when necessary, so it unsurprisingly favors Network Manager. –  Gilles Jul 31 '12 at 22:49

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/dhclient-random-numbers-eth1.lease. Look for the most recent file associated with the interface you're interested in and open it up:

cat /var/lib/dhcp/dhclient-...-eth1.lease

The output should be something like this:

lease {
  interface "eth1";
  fixed-address 192.168.10.12;
  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.

share|improve this answer
    
Thank you for your answer, but as I am using the User Interface, I got it sorted. But thanks again. –  Kevdog777 Aug 2 '12 at 7:39

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.

share|improve this answer
    
This is a very long-winded answer - and only the real part in this "answer" is the last paragraph. –  Kevdog777 May 11 at 7:55

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.