# Secondary IP addresses not working with security groups

**URL:** <https://forum.opennebula.io/t/secondary-ip-addresses-not-working-with-security-groups/9863>\
**Category:** Installation & Configuration\
**Created:** [August 19, 2021, 8:24pm UTC](https://forum.opennebula.io/t/secondary-ip-addresses-not-working-with-security-groups/9863 "2021-08-19T20:24:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gigatux](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/gigatux/32/7085_2.png) [@gigatux](https://forum.opennebula.io/u/gigatux)\
**Post date:** [August 19, 2021, 8:24pm UTC](https://forum.opennebula.io/t/secondary-ip-addresses-not-working-with-security-groups/9863/1 "2021-08-19T20:24:12Z")

</div>

Hello,

I have a virtual network under “Bridged & Security Groups” mode.

I have a VM with an IP address 185.113.128.31 and an aliased IP address 185.113.128.32.

I am unable to ping from the aliased IP address even though everything appears to be configured correctly. I can ping from the .31 IP address just fine.

From what I can tell, the problem appears to be with ipset.

My iptables rules for this particular VM are:

```auto
Chain opennebula (1 references)
target prot opt source destination         
one-22-1-o all -- 185.113.128.32 0.0.0.0/0 PHYSDEV match --physdev-in one-22-0 --physdev-is-bridged
one-22-1-i all -- 0.0.0.0/0 185.113.128.32 PHYSDEV match --physdev-out one-22-0 --physdev-is-bridged
one-22-0-o all -- 0.0.0.0/0 0.0.0.0/0 PHYSDEV match --physdev-in one-22-0 --physdev-is-bridged
one-22-0-i all -- 0.0.0.0/0 0.0.0.0/0 PHYSDEV match --physdev-out one-22-0 --physdev-is-bridged

```

Which makes sense. The outbound chain in question is:

```auto
Chain one-22-1-o (1 references)
target prot opt source destination         
RETURN udp -- 0.0.0.0 255.255.255.255 udp spt:68 dpt:67
DROP all -- 0.0.0.0/0 0.0.0.0/0 ! match-set one-22-1-ip-spoofing src
RETURN all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
RETURN all -- 0.0.0.0/0 0.0.0.0/0           
DROP all -- 0.0.0.0/0 0.0.0.0/0

```

Which also makes sense. However, the match-set argument for this (via ipset list) is:

```auto
# ipset list one-22-0-ip-spoofing
Name: one-22-0-ip-spoofing
Type: hash:ip
Revision: 4
Header: family inet hashsize 1024 maxelem 65536
Size in memory: 296
References: 1
Number of entries: 1
Members:
185.113.128.31

```

From the above, it appears to be missing the aliased IP address.

If I run `ipset add one-22-0-ip-spoofing 185.113.128.32` then I can ping from the IP address correctly.

Is this a bug? This is with OpenNebula 6.0.0.2.

Thanks,

Marc

---

<div class="post-metadata">

**Author:** ![cgonzalez](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/cgonzalez/32/7096_2.png) [@cgonzalez](https://forum.opennebula.io/u/cgonzalez)\
**Post date:** [August 20, 2021, 11:36am UTC](https://forum.opennebula.io/t/secondary-ip-addresses-not-working-with-security-groups/9863/2 "2021-08-20T11:36:34Z")

</div>

Hello @gigatux,

Did you add the IP alias by [using OpenNebula](https://docs.opennebula.io/6.0/management_and_operations/network_management/manage_vnets.html#attach-a-nic-alias-to-a-virtual-machine) or manually from inside the VM?

---

<div class="post-metadata">

**Author:** ![gigatux](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/gigatux/32/7085_2.png) [@gigatux](https://forum.opennebula.io/u/gigatux)\
**Post date:** [August 20, 2021, 11:38am UTC](https://forum.opennebula.io/t/secondary-ip-addresses-not-working-with-security-groups/9863/3 "2021-08-20T11:38:07Z")

</div>

@cgonzalez Using OpenNebula Sunstone.

---

<div class="post-metadata">

**Author:** ![rdiaz](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/rdiaz/32/6416_2.png) [@rdiaz](https://forum.opennebula.io/u/rdiaz)\
**Post date:** [August 23, 2021, 2:50pm UTC](https://forum.opennebula.io/t/secondary-ip-addresses-not-working-with-security-groups/9863/4 "2021-08-23T14:50:32Z")

</div>

Hi @gigatux,

You are right, it’s a bug that was fixed in this [commit](https://github.com/OpenNebula/one/commit/b4ea449e544ec4dda82a857b2001b6d4cdd66070). It will be included in the upcoming OpenNebula releases. Thanks for the heads up.

Cheers.

---

<div class="post-metadata">

**Author:** ![gigatux](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/gigatux/32/7085_2.png) [@gigatux](https://forum.opennebula.io/u/gigatux)\
**Post date:** [August 26, 2021, 2:47pm UTC](https://forum.opennebula.io/t/secondary-ip-addresses-not-working-with-security-groups/9863/5 "2021-08-26T14:47:14Z")

</div>

Hi @rdiaz ,

Thanks for the commit info!

I’ve given it a bit of a bodge-test in my environment, just replacing the affected .rb file which I hope is enough. I think there’s still an issue though.

From what I can see, this now correctly creates a load of rules in the _opennebula_ chain, e.g.:

```auto
Chain opennebula (1 references)
num pkts bytes target prot opt in out source destination         
1 280 14442 one-32-2-o all -- * * 185.113.129.159 0.0.0.0/0 PHYSDEV match --physdev-in one-32-0 --physdev-is-bridged
2 337 16851 one-32-2-i all -- * * 0.0.0.0/0 185.113.129.159 PHYSDEV match --physdev-out one-32-0 --physdev-is-bridged
3 2273 181K one-32-1-o all -- * * 185.113.129.158 0.0.0.0/0 PHYSDEV match --physdev-in one-32-0 --physdev-is-bridged
4 272 13351 one-32-1-i all -- * * 0.0.0.0/0 185.113.129.158 PHYSDEV match --physdev-out one-32-0 --physdev-is-bridged
5 3477 262K one-32-0-o all -- * * 0.0.0.0/0 0.0.0.0/0 PHYSDEV match --physdev-in one-32-0 --physdev-is-bridged
6 2221 254K one-32-0-i all -- * * 0.0.0.0/0 0.0.0.0/0 PHYSDEV match --physdev-out one-32-0 --physdev-is-bridged

```

Outbound packets from 185.113.129.158 correctly skip rules 1 and 2, and enter the chain referenced in the third rule, _one-32-1-o_. They then correctly pass the _match-set_ in that chain and hits the _RETURN_ target.

However, the packet continues to traverse the _opennebula_ chain, skipping rule 4 and hitting rule 5, which is the _one-32-0-o_ chain:

```auto
Chain one-32-0-o (1 references)
num pkts bytes target prot opt in out source destination         
1 0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 MAC !02:00:b9:71:00:01
2 0 0 RETURN udp -- * * 0.0.0.0 255.255.255.255 udp spt:68 dpt:67
3 2771 217K DROP all -- * * 0.0.0.0/0 0.0.0.0/0 ! match-set one-32-0-ip-spoofing src
4 751 52475 RETURN all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
5 338 22913 RETURN all -- * * 0.0.0.0/0 0.0.0.0/0           
6 0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0           

```

Of course, the _one-32-0-ip-spoofing_ set just contains the primary IP address:

```auto
Name: one-32-0-ip-spoofing
Type: hash:ip
Revision: 4
Header: family inet hashsize 1024 maxelem 65536
Size in memory: 248
References: 1
Number of entries: 1
Members:
185.113.129.157

```

And because this doesn’t match, the packet is dropped.

What are your thoughts? Is there still a bug remaining?

Thanks,

Marc

---

<div class="post-metadata">

**Author:** ![rdiaz](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/rdiaz/32/6416_2.png) [@rdiaz](https://forum.opennebula.io/u/rdiaz)\
**Post date:** [August 26, 2021, 6:56pm UTC](https://forum.opennebula.io/t/secondary-ip-addresses-not-working-with-security-groups/9863/6 "2021-08-26T18:56:51Z")

</div>

Hi @gigatux,

After changing the script, you must run `onehost sync -f` to force synchronization of the scripts on the nodes.

On the other hand, this [commit](https://github.com/OpenNebula/one/commit/ef2bfcdc2d54cf0ee4a7b696d911c8a4c5a05f88) is a fix for IPv6.

Cheers.

---

<div class="post-metadata">

**Author:** ![gigatux](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/gigatux/32/7085_2.png) [@gigatux](https://forum.opennebula.io/u/gigatux)\
**Post date:** [August 26, 2021, 8:20pm UTC](https://forum.opennebula.io/t/secondary-ip-addresses-not-working-with-security-groups/9863/7 "2021-08-26T20:20:39Z")

</div>

Hi @rdiaz ,

Thanks for that. I didn’t know about the synchronisation script - I assumed the SSH connection did the firewall rules.

Using both the update _security\_groups\_iptables.rb_ and _command.rb_ ended up with deployments totally failing.

![image](https://canada1.discourse-cdn.com/flex031/uploads/opennebula/original/2X/9/92499c28c70710f353a943ea39dfc100e8ea8676.png)

Honestly, this could be due to anything as I’m well aware I’m cherry picking two files that are probably related to a whole load of other files in the git HEAD so I’ll back off with this one, at least until this goes into a community release.

Many thanks.

---

<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:** [August 27, 2021, 3:05pm UTC](https://forum.opennebula.io/t/secondary-ip-addresses-not-working-with-security-groups/9863/8 "2021-08-27T15:05:12Z")

</div>

Hi @gigatux

There is an [addon-vnfilter](https://github.com/storpool/addon-vnfilter) that resolves the spoofing related issues with the alias IPs since v5.10 was released…

You could give it a try if you need the functionality.

Best Regards,  
Anton Todorov
