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 have a virtual machine/LXC container that is using a bridge (on br0) to access the network.

On the system that is hosting the virtual machine and the bridge, I would like to be able to tell what IP address was assigned (dhcp).

I don't want to go into the virtual machine and use ifconfig...I want to be able to tell from the host of the virtual machine.

When I use ifconfig on the host system I get the following:

br0       Link encap:Ethernet  HWaddr 08:00:27:28:05:9e  
          inet addr:192.168.42.216  Bcast:192.168.42.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe28:59e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1652 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2577 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:174997 (174.9 KB)  TX bytes:256212 (256.2 KB)

eth0      Link encap:Ethernet  HWaddr 08:00:27:28:05:9e  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1729 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2580 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:206750 (206.7 KB)  TX bytes:256022 (256.0 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:4239 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4239 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:758585 (758.5 KB)  TX bytes:758585 (758.5 KB)

vethUcRl21 Link encap:Ethernet  HWaddr 92:70:c3:64:6c:bc  
          inet6 addr: fe80::9070:c3ff:fe64:6cbc/64 Scope:Link
          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
          RX packets:7 errors:0 dropped:0 overruns:0 frame:0
          TX packets:28 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:546 (546.0 B)  TX bytes:3280 (3.2 KB)

vethUcRl21 is the virtual interface created which uses the br0 interface.

share|improve this question
1  
What hypervisor are you using? –  Bart Silverstrim Dec 8 '11 at 13:57
    
I'm using LXC containers, but I don't think the problem depends on this information, so I just said virtual machine. –  Martin Konecny Dec 8 '11 at 14:40
    
I was asking because some hypervisors have methods to get the information from a management console/interface. LXC isn't really a hypervisor/VM system so that option goes out the window... –  Bart Silverstrim Dec 8 '11 at 15:07
    
You're right, LXC has an option "lxc-netstat" which runs netstat inside the container. A shame "lxc-ifconfig" does not exist. –  Martin Konecny Dec 12 '11 at 17:10
add comment

3 Answers

up vote 2 down vote accepted

I came here looking for the answer to the same problem. After reading Fox's answer, I discovered arp tables management command (now obsolete). Try ip neigh this is the same as arp. This will show you the VMs IP address being propagated via DHCP from the host sharing the same link (the virtual bridge).

share|improve this answer
add comment

Short of looking at DHCP logs... or capturing packets and filtering for DHCP packets... you're going to be out of luck. The host doesn't care what IP address is assigned to the virtual machines it's hosting. The bridge simply takes all data from one interface in the bridge and broadcasts it to all other interfaces in the bridge. The host itself knows nothing about how the data is processed by the other devices in the bridge.

share|improve this answer
add comment

You probably could use ARP daemon (ie. arpd) to monitor the bridge interface. As long as you know the MAC address of the virtual machine, you can get it from it's database. And MACs you can find in brctl showmacs br0.

share|improve this answer
add comment

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.