how to find which ips are in use ?

shukko

New Member
Oct 24, 2008
23
3
3
Hello

I've got a 3 host cluster proxmox system running with 12 openvz installations.
Each openvz vm have 3-5 ip addresses each.
I can find them by entering each vm and clicking network tab.
But checking all 12 vm's take time.
Is there an easy way to manage ips given to each vm?

I mean how can I easily list all used ips in my proxmox cluster system and which ip belongs to which vm id ?
 

udo

Famous Member
Apr 22, 2009
5,887
166
83
Ahrensburg; Germany
Hello

I've got a 3 host cluster proxmox system running with 12 openvz installations.
Each openvz vm have 3-5 ip addresses each.
I can find them by entering each vm and clicking network tab.
But checking all 12 vm's take time.
Is there an easy way to manage ips given to each vm?

I mean how can I easily list all used ips in my proxmox cluster system and which ip belongs to which vm id ?
Hi,
whats about something like this executed on the master:
Code:
hosts=`grep IP: /etc/pve/cluster.cfg | awk '{print $2}'`
for h in $hosts; do
  ssh $h ip=`ifconfig | grep veth | grep -o [1-9][0-9][0-9] | sort -u`;\
         for i in $ip; do \
            echo "ip in $i:"; \
            echo `vzctl exec $i "LANG=C;ifconfig|grep 'inet addr'| grep -v 127.0.0.1"` | awk -F: '{ print $2 }' | tr -d " Bcast"; \
         done
done
I don't have more than one IP per openvz-vm, so i can't test the script.
Of course you can write a smarter script which do the most things in awk...

Udo
 
Last edited:

shukko

New Member
Oct 24, 2008
23
3
3
Thanks Udo but your script is not working, I don't know why.
Anyway
after checking your script I found a better and easy way to achive what I need.
The command I needed is "vzlist"
1 single command:

Code:
vzlist -o hostname,ctid,ip
gives me the exact result I needed.

If anybody interested you can read more about vzlist here:

http://download.swsoft.com/virtuozzo/virtuozzo4.0/docs/en/win/VzWindowsReference/4549.htm
and here:
http://download.swsoft.com/virtuozzo/virtuozzo4.0/docs/en/win/VzWindowsReference/4615.htm
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE and Proxmox Mail Gateway. We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!