Hi all,
Somebody knows how can I extract/know an ip address used by a kvm guest using a script?? For example I have the following guests:
[root@kvmsrv01 bin]# virsh list --all Id Name State ---------------------------------- 1 linclunode01 running 2 linmgmt running 5 win7desktop running
I know that linclunode01 has 172.25.50.1 as ip address, linmgmt has 172.25.50.2 and so on. But suppose that i don't know which ip address is used by win7desktop guest. The real fqdn for win7desktop is win7.local.net. How can I know its real ip using a script (bash, python, etc)?? I don't use a dhcp or dns server on this network.
Thanks.
--- On Sat, 4/23/11, carlopmart carlopmart@gmail.com wrote:
From: carlopmart carlopmart@gmail.com Subject: [CentOS-virt] Extract ip address from a kvm guest To: centos-virt@centos.org Date: Saturday, April 23, 2011, 8:07 AM Hi all,
Somebody knows how can I extract/know an ip address used by a kvm guest using a script?? For example I have the following guests:
[root@kvmsrv01 bin]# virsh list --all Id Name State
1 linclunode01 running 2 linmgmt running 5 win7desktop running
I know that linclunode01 has 172.25.50.1 as ip address, linmgmt has 172.25.50.2 and so on. But suppose that i don't know which ip address is used by win7desktop guest. The real fqdn for win7desktop is
win7.local.net. How can I know its real ip using a script (bash, python, etc)?? I don't use a dhcp or dns server on this network.
If you have an http server on the local network:
Inside the VM guest:
------------ /etc/rc.local ------------ wget --spider http://192.168.1.1/favicon.ico?sl6bs?ga-p45 ------------ snip ---------
where the web server is at 192.168.1.1, Virt host is ga-p45, and the VM guest is sl6bs.
In the server logs I see: $ sudo tail -n 175 /var/log/apache2/local_log | grep fav 192.168.1.224 - - [23/Apr/2011:10:10:02 -0700] "HEAD /favicon.ico?lucidpv?ga-p45 HTTP/1.0" 200 296 192.168.1.155 - - [23/Apr/2011:10:10:10 -0700] "HEAD /favicon.ico?centbs?ga-p45 HTTP/1.0" 200 296 192.168.1.183 - - [23/Apr/2011:10:10:10 -0700] "HEAD /favicon.ico?sl6bs?ga-p45 HTTP/1.0" 200 296
On 04/23/2011 07:32 PM, Mark Pryor wrote:
--- On Sat, 4/23/11, carlopmartcarlopmart@gmail.com wrote:
From: carlopmartcarlopmart@gmail.com Subject: [CentOS-virt] Extract ip address from a kvm guest To: centos-virt@centos.org Date: Saturday, April 23, 2011, 8:07 AM Hi all,
Somebody knows how can I extract/know an ip address used by a kvm guest using a script?? For example I have the following guests:
[root@kvmsrv01 bin]# virsh list --all Id Name State
1 linclunode01 running 2 linmgmt running 5 win7desktop
running
I know that linclunode01 has 172.25.50.1 as ip address, linmgmt has 172.25.50.2 and so on. But suppose that i don't know which ip address is used by win7desktop guest. The real fqdn for win7desktop is
win7.local.net. How can I know its real ip using a script (bash, python, etc)?? I don't use a dhcp or dns server on this network.
If you have an http server on the local network:
Inside the VM guest:
------------ /etc/rc.local ------------ wget --spider http://192.168.1.1/favicon.ico?sl6bs?ga-p45 ------------ snip ---------
where the web server is at 192.168.1.1, Virt host is ga-p45, and the VM guest is sl6bs.
In the server logs I see: $ sudo tail -n 175 /var/log/apache2/local_log | grep fav 192.168.1.224 - - [23/Apr/2011:10:10:02 -0700] "HEAD /favicon.ico?lucidpv?ga-p45 HTTP/1.0" 200 296 192.168.1.155 - - [23/Apr/2011:10:10:10 -0700] "HEAD /favicon.ico?centbs?ga-p45 HTTP/1.0" 200 296 192.168.1.183 - - [23/Apr/2011:10:10:10 -0700] "HEAD /favicon.ico?sl6bs?ga-p45 HTTP/1.0" 200 296
Interesting Mark, but I don't have a http server installed. And between kvm host and kvm guests exists a firewall. Then, I can¡t use ping, telnet or other tools ...
I am searching some type of function inside libvirt that can says what ip address has one kvm guest ...
Thanks.
On Sat, Apr 23, 2011 at 10:46 AM, carlopmart carlopmart@gmail.com wrote:
On 04/23/2011 07:32 PM, Mark Pryor wrote:
--- On Sat, 4/23/11, carlopmartcarlopmart@gmail.com wrote:
Somebody knows how can I extract/know an ip address used by a kvm
etc)?? I don't use a dhcp or dns server on this network.
If you have an http server on the local network:
Inside the VM guest:
------------ /etc/rc.local ------------ wget --spider http://192.168.1.1/favicon.ico?sl6bs?ga-p45 ------------ snip ---------
where the web server is at 192.168.1.1, Virt host is ga-p45, and the VM guest is sl6bs.
In the server logs I see: $ sudo tail -n 175 /var/log/apache2/local_log | grep fav 192.168.1.224 - - [23/Apr/2011:10:10:02 -0700] "HEAD /favicon.ico?lucidpv?ga-p45 HTTP/1.0" 200 296 192.168.1.155 - - [23/Apr/2011:10:10:10 -0700] "HEAD /favicon.ico?centbs?ga-p45 HTTP/1.0" 200 296 192.168.1.183 - - [23/Apr/2011:10:10:10 -0700] "HEAD /favicon.ico?sl6bs?ga-p45 HTTP/1.0" 200 296
Interesting Mark, but I don't have a http server installed. And between kvm host and kvm guests exists a firewall. Then, I can¡t use ping, telnet or other tools ...
I am searching some type of function inside libvirt that can says what ip address has one kvm guest ...
There was a thread on a similar question. One of the answers (arpwatch) may be useful :
http://lists.centos.org/pipermail/centos/2010-July/096998.html
Akemi
On 04/23/2011 08:09 PM, Akemi Yagi wrote:
On Sat, Apr 23, 2011 at 10:46 AM, carlopmartcarlopmart@gmail.com wrote:
On 04/23/2011 07:32 PM, Mark Pryor wrote:
--- On Sat, 4/23/11, carlopmartcarlopmart@gmail.com wrote:
Somebody knows how can I extract/know an ip address
used by a kvm
etc)?? I don't use a dhcp or dns server on this network.
If you have an http server on the local network:
Inside the VM guest:
------------ /etc/rc.local ------------ wget --spider http://192.168.1.1/favicon.ico?sl6bs?ga-p45 ------------ snip ---------
where the web server is at 192.168.1.1, Virt host is ga-p45, and the VM guest is sl6bs.
In the server logs I see: $ sudo tail -n 175 /var/log/apache2/local_log | grep fav 192.168.1.224 - - [23/Apr/2011:10:10:02 -0700] "HEAD /favicon.ico?lucidpv?ga-p45 HTTP/1.0" 200 296 192.168.1.155 - - [23/Apr/2011:10:10:10 -0700] "HEAD /favicon.ico?centbs?ga-p45 HTTP/1.0" 200 296 192.168.1.183 - - [23/Apr/2011:10:10:10 -0700] "HEAD /favicon.ico?sl6bs?ga-p45 HTTP/1.0" 200 296
Interesting Mark, but I don't have a http server installed. And between kvm host and kvm guests exists a firewall. Then, I can¡t use ping, telnet or other tools ...
I am searching some type of function inside libvirt that can says what ip address has one kvm guest ...
There was a thread on a similar question. One of the answers (arpwatch) may be useful :
http://lists.centos.org/pipermail/centos/2010-July/096998.html
Akemi
Arpwatch is a correct solution when host and guests are in the same network, but in my environment, they are in different nets with a firewall in the middle...
Maybe some virsh option??
And if you can't run arpwatch on such router, you could try SNMP to query the ARP table on the router.
On 24/04/2011, at 1:35 PM, Manuel Wolfshant wrote:
On 04/23/2011 09:27 PM, carlopmart wrote:
Arpwatch is a correct solution when host and guests are in the same network, but in my environment, they are in different nets with a firewall in the middle...
I run arpwatch on the core router which sits between all VLANs
CentOS-virt mailing list CentOS-virt@centos.org http://lists.centos.org/mailman/listinfo/centos-virt
On 04/24/2011 07:27 AM, Cameron Kerr wrote:
And if you can't run arpwatch on such router, you could try SNMP to query the ARP table on the router.
On 24/04/2011, at 1:35 PM, Manuel Wolfshant wrote:
On 04/23/2011 09:27 PM, carlopmart wrote:
Arpwatch is a correct solution when host and guests are in the same network, but in my environment, they are in different nets with a firewall in the middle...
I run arpwatch on the core router which sits between all VLANs
If I put arpwatch on the router side, I will see firewall ip address only, because firewall does a nat over all networks behind it ...