# How to find out all allocated IP's in OpenNebula

**URL:** <https://forum.opennebula.io/t/how-to-find-out-all-allocated-ips-in-opennebula/8262>\
**Category:** Product Support\
**Created:** [March 30, 2020, 5:58am UTC](https://forum.opennebula.io/t/how-to-find-out-all-allocated-ips-in-opennebula/8262 "2020-03-30T05:58:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![TomK](https://avatars.discourse-cdn.com/v4/letter/t/ee59a6/32.png) [@TomK](https://forum.opennebula.io/u/TomK)\
**Post date:** [March 30, 2020, 5:58am UTC](https://forum.opennebula.io/t/how-to-find-out-all-allocated-ips-in-opennebula/8262/1 "2020-03-30T05:58:50Z")

</div>

I can run the following to show me all the leased IP’s for each network:

$ onevnet show

but how do I find out ALL the leased IP’s for ALL the defined networks with a single command? I could call onvnet show through a loop over all the networks but that is slow and rather ugly. Looking for a single command, if possible.

Thx,

---

<div class="post-metadata">

**Author:** ![atodorov\_storpool](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/atodorov_storpool/32/5327_2.png) [@atodorov\_storpool](https://forum.opennebula.io/u/atodorov_storpool)\
**Post date:** [March 30, 2020, 6:40am UTC](https://forum.opennebula.io/t/how-to-find-out-all-allocated-ips-in-opennebula/8262/2 "2020-03-30T06:40:41Z")

</div>

You can use `onevnet list --xml` and process the output (XML format)

---

<div class="post-metadata">

**Author:** ![TomK](https://avatars.discourse-cdn.com/v4/letter/t/ee59a6/32.png) [@TomK](https://forum.opennebula.io/u/TomK)\
**Post date:** [March 30, 2020, 11:51am UTC](https://forum.opennebula.io/t/how-to-find-out-all-allocated-ips-in-opennebula/8262/3 "2020-03-30T11:51:06Z")

</div>

Thank you. However, this doesn’t show the leases.

```
[oneadmin@srv01 ~]$ onevnet list --xml | grep -Ei 10.0.0.102
[oneadmin@srv01 ~]$

```

vs

```
[oneadmin@srv01 ~]$ onevnet show 26 --xml | grep -Ei 10.0.0.102
          <IP><![CDATA[10.0.0.102]]></IP>
[oneadmin@srv01 ~]$

```

Thx

---

<div class="post-metadata">

**Author:** ![atodorov\_storpool](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/atodorov_storpool/32/5327_2.png) [@atodorov\_storpool](https://forum.opennebula.io/u/atodorov_storpool)\
**Post date:** [March 30, 2020, 12:57pm UTC](https://forum.opennebula.io/t/how-to-find-out-all-allocated-ips-in-opennebula/8262/4 "2020-03-30T12:57:01Z")

</div>

The IP adresses are in the _AR\_POOL/AR/ALLOCATED_ element of the returned XML. The format of this field is space separated list of `INDEX ENCODED_VMID`.

For example, if you have the following _AR\_POOL/AR_:

```auto
  <AR_POOL>
    <AR>
      <ALLOCATED><![CDATA[1 68719477428 2 68719477429 3 68719477432 4 68719477433 5 68719477434 6 68719477435 7 68719477436 8 68719477438 9 68719477440]]></ALLOCATED>
      <AR_ID><![CDATA[1]]></AR_ID>
      <IP><![CDATA[10.2.1.40]]></IP>
      <MAC><![CDATA[02:00:0a:02:01:28]]></MAC>
      <SIZE><![CDATA[40]]></SIZE>
      <TYPE><![CDATA[IP4]]></TYPE>
    </AR>
  </AR_POOL>

```

There are 9 IPs allocated, with start IP `10.2.1.40`.  
So you convert the first _IP Address_ to _IP Number_ and add the `INDEX`. Then convert back the result from _IP Number_ to _IP Address_ to have the dot notation.

For example, the last allocated IP is `167903528 + 9 = 167903537` where `167903537` is `10.2.1.49`.

Hope this helps.

Best Regards,  
Anton Todorov

---

<div class="post-metadata">

**Author:** ![TomK](https://avatars.discourse-cdn.com/v4/letter/t/ee59a6/32.png) [@TomK](https://forum.opennebula.io/u/TomK)\
**Post date:** [April 7, 2020, 4:04pm UTC](https://forum.opennebula.io/t/how-to-find-out-all-allocated-ips-in-opennebula/8262/5 "2020-04-07T16:04:05Z")

</div>

Thanks Anton. Got it.

What are numbers such as these?

68719477428 , 68719477429 , etc

If I’m just using the 1,2,3,4 etc.

Thx,  
TK

---

<div class="post-metadata">

**Author:** ![atodorov\_storpool](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/atodorov_storpool/32/5327_2.png) [@atodorov\_storpool](https://forum.opennebula.io/u/atodorov_storpool)\
**Post date:** [April 8, 2020, 6:30am UTC](https://forum.opennebula.io/t/how-to-find-out-all-allocated-ips-in-opennebula/8262/6 "2020-04-08T06:30:33Z")

</div>

> [@TomK](#):
>
> What are numbers such as these?
> 
> 68719477428 , 68719477429 , etc
> 
> If I’m just using the 1,2,3,4 etc.

These values are referenced as _“binary\_magic”_ in the OpenNebula code. The upper part of this 64bit value defines the [type](https://github.com/OpenNebula/one/blob/44e44b47a859f03bac3177c879c7d1ff3f83c2b3/src/onedb/fsck.rb#L90) of the allocation, currently VM, VNet or VRouter. The lower value is the OID of the entry in case of VM, it is the VM’s ID. The value of _0xFFFFFFFF_ defines the allocation as on _HOLD_.

I’ve found the best summary in the network’s section of _onedb fsck_ : [https://github.com/OpenNebula/one/blob/c26b6d470536b4c549c1968ac665716a78202eb4/src/onedb/fsck/network.rb#L473](https://github.com/OpenNebula/one/blob/c26b6d470536b4c549c1968ac665716a78202eb4/src/onedb/fsck/network.rb#L473)

Hope this helps.

Best Regards,  
Anton Todorov
