[Users] Re: How to identify the physical machine when you are inside the container?

Aleksandar Ivanisevic aleksandar at ivanisevic.de
Tue May 10 05:09:42 EDT 2011


Benjamin Henrion <bh at udev.org> writes:

> Hi,
>
> Do you have any trick to identify the physical machine (with some kind
> of cat /proc/something) when you are inside the container?
>
> I want to just get the hostname of the HN when I am inside the containers.
>
> Any simple of doing it?

I use this with venet:

export ovz_host=$(dig -x $(ping -t 1 -c 1 1.2.3.4 | grep exceed | cut -d " " -f 2) +short | sed -e s/\.$// )

it sends a ping packet with the time to live of 1 hop and checks who
responds with icmp time exceeded. For a VE with p2p network (venet), a
host node is always the next hop. It will not work if you have veth as
bridges dont return icmp ;)

dont forget to set up the dns properly or change the dig above to a
hosts or other table lookup.



More information about the Users mailing list