OpenVZ Forum


Home » Mailing lists » Users » How to identify the physical machine when you are inside the container?
How to identify the physical machine when you are inside the container? [message #42646] Mon, 09 May 2011 08:13 Go to next message
Benjamin Henrion is currently offline  Benjamin Henrion
Messages: 51
Registered: February 2011
Member
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?

Best,

--
Benjamin Henrion <bhenrion at ffii.org>
FFII Brussels - +32-484-566109 - +32-2-4148403
"In July 2005, after several failed attempts to legalise software
patents in Europe, the patent establishment changed its strategy.
Instead of explicitly seeking to sanction the patentability of
software, they are now seeking to create a central European patent
court, which would establish and enforce patentability rules in their
favor, without any possibility of correction by competing courts or
democratically elected legislators."
Re: How to identify the physical machine when you are inside the container? [message #42663 is a reply to message #42646] Tue, 10 May 2011 09:09 Go to previous messageGo to next message
Aleksandar Ivanisevic is currently offline  Aleksandar Ivanisevic
Messages: 34
Registered: April 2011
Member
Benjamin Henrion <bh@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.
Re: Re: How to identify the physical machine when you are inside the container? [message #42668 is a reply to message #42663] Tue, 10 May 2011 14:43 Go to previous messageGo to next message
mercy is currently offline  mercy
Messages: 12
Registered: October 2010
Location: msk.ru.earth
Junior Member

Hi.

For this purpose we use special naming sheme:
hostname of VE contain name of NH as service hostname.
i.e. 1111.ovz1.domain.ru, 2222.ovz2.domain.ru, 3333.ovz3.domain.ru and
VEID is uniq for ALL HN's

Or we can use traceroute utility from outside
i.e. traceroute ve-domain.com
traceroute to ve-domain.com (xxx.xxx.xxx.xxx), 30 hops max, 60 byte packets
1 ....
2 ....
3 ....
HW name -->> 4 hwnodename.domain.com (yyy.yyy.yyy.yyy.) 2.775 ms
2.762 ms 2.741 ms
5 ve-domain.com (xxx.xxx.xxx.xxx) 2.727 ms 2.702 ms
2.687 ms

If VE and HN has real IP and HN's , you can use traceroute inside VE
i.e. traceroute ya.ru
traceroute to ya.ru (87.250.251.3), 30 hops max, 40 byte packets
HW name -->> 1 hwhonename (yyy.yyy.yyy.yyy) 0.090 ms 0.015 ms 0.015 ms
2 ...
3 ...
4 ...
5 ...
6 www.yandex.ru (87.250.251.3) 1.510 ms 1.907 ms 2.116 ms


On 05/10/2011 01:09 PM, Aleksandar Ivanisevic wrote:
> Benjamin Henrion<bh@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.
>


no fear. never give up. never surrender.
Re: How to identify the physical machine when you are inside the container? [message #42683 is a reply to message #42668] Wed, 11 May 2011 08:50 Go to previous messageGo to next message
Aleksandar Ivanisevic is currently offline  Aleksandar Ivanisevic
Messages: 34
Registered: April 2011
Member
"Ekaterina.epifanova" <nixma@yandex.ru>
writes:

> Hi.
>
> For this purpose we use special naming sheme:
> hostname of VE contain name of NH as service hostname.

You never migrate VEs? Or when they move they get a new name?

> i.e. 1111.ovz1.domain.ru, 2222.ovz2.domain.ru, 3333.ovz3.domain.ru and
> VEID is uniq for ALL HN's
>
> Or we can use traceroute utility from outside

How does that work if you are inside? you ssh somewhere outside and
get the traceroute?


[...]
Re: Re: How to identify the physical machine when you are inside the container? [message #42687 is a reply to message #42683] Wed, 11 May 2011 10:10 Go to previous messageGo to next message
mercy is currently offline  mercy
Messages: 12
Registered: October 2010
Location: msk.ru.earth
Junior Member

11.05.2011, 12:50, "Aleksandar Ivanisevic" <aleksandar@ivanisevic.de>:
> "Ekaterina.epifanova" <nixma@yandex.ru>;
> writes:
>
>>  Hi.
>>
>>  For this purpose we use special naming sheme:
>>  hostname of VE contain name of NH as service hostname.
>
> You never migrate VEs? Or when they move they get a new name?

In our enviroment (~100HNs and ~7000VEs) veid.hwnodename.domain.com - it's service name and it never use for http, smtp or other VEs needs.
After migrating VE it's service name must be changed to correct

Mirgating VE - it's not everyday job. In this case VE's serivce name may be created and changed by hand or, in large scale, with automated scripts.

>
>>  i.e. 1111.ovz1.domain.ru, 2222.ovz2.domain.ru, 3333.ovz3.domain.ru and
>>  VEID is uniq for ALL HN's
>>
>>  Or we can use traceroute utility from outside
>
> How does that work if you are inside? you ssh somewhere outside and
> get the traceroute?
>
>From inside we can use traceroute from inside. First hop will be HN

> [...]
>


no fear. never give up. never surrender.
Re: How to identify the physical machine when you are inside the container? [message #42689 is a reply to message #42687] Wed, 11 May 2011 13:06 Go to previous messageGo to next message
Aleksandar Ivanisevic is currently offline  Aleksandar Ivanisevic
Messages: 34
Registered: April 2011
Member
Epifanova Ekaterina <nixma@yandex.ru>
writes:

>From inside we can use traceroute from inside. First hop will be HN

thats exactly what I do, but that only works for venet, I hoped you
have something that will work for veth.
Re: How to identify the physical machine when you are inside the container? [message #42691 is a reply to message #42646] Wed, 11 May 2011 20:08 Go to previous message
Thorsten Schifferdeck is currently offline  Thorsten Schifferdeck
Messages: 38
Registered: February 2006
Member
Hi,

you can use action scripts mount, see OpenVZ User Guide,
p. 89 (-> http://download.openvz.org/doc/OpenVZ-Users-Guide.pdf )
or man page vzctl (8)

on ct mount, a ct0 hostname info is writen inside the ct, like:


---8<... ...( file: /etc/vz/conf/vps.mount )...
#!/bin/bash

# global vps.mount script
# write hostname ct0 info from ct0 to ctX

# include the ct config
. $VE_CONFFILE

hostname > $VE_PRIVATE/_to/any/place/where/you/like/it_

exit 0
---8<...

Bye,
Thorsten

Am 09.05.2011 10:13, schrieb Benjamin Henrion:
> 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?
>
> Best,
>
> --
> Benjamin Henrion <bhenrion at ffii.org>
> FFII Brussels - +32-484-566109 - +32-2-4148403
> "In July 2005, after several failed attempts to legalise software
> patents in Europe, the patent establishment changed its strategy.
> Instead of explicitly seeking to sanction the patentability of
> software, they are now seeking to create a central European patent
> court, which would establish and enforce patentability rules in their
> favor, without any possibility of correction by competing courts or
> democratically elected legislators."
Previous Topic: /usr/sbin/vzmigrate: line 312: vzctl: command not found
Next Topic: Slackware 13 weirdness
Goto Forum:
  


Current Time: Tue Nov 05 01:24:23 GMT 2024

Total time taken to generate the page: 0.03389 seconds