Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I couldn't find any way to achieve the above by means of neutron meter-label-rule which is a shame. If you find anything, please do contribute so others can benefit...

So I had to resort to configuring the guest to egress the traffic I need excluding via a separate source IP (here the intention is to use 192.168.1.5 but read below on IP assignment) so this traffic doesn't get metered. Here's how I did it:

$ neutron port-list
# figure out the right port then add an IP address (on the same subnet) as follows:
$ neutron port-update --fixed-ip subnet_id=<subnet_id>,ip_address=192.168.1.4\
   --fixed-ip subnet_id=<subnet_id>,ip_address=192.168.1.5 <port_id>

Now this gets a little tricky: the port has both IPs (check with neutron port-show <port_id>) but I haven't found a way to control how they get assigned to the VM (seems a "collaboration" between cloud-init and DHCP). In any case, what happened here is that the instance's eth0 got its IP address swapped pretty much instantly to the one I wanted to use for the separate traffic. It's a bit annoying because I had to reconfigure things (including the above metering-label-rule) but at least the behaviour appears deterministic, even after a number of reboots.

So once you've worked out which IP your guest now has for its primary NIC, it's a matter of configuring a sub-interface to use for the secondary IP, and an appropriate route. Here's how I did it (this is a Ubuntu 14.04.3 guest):

$ cat << EOF | sudo tee /etc/network/interfaces.d/eth0:1.cfg
auto eth0:1
    iface eth0:1 inet static
    address 192.168.1.4/24
    up ip route add 10.10.0.123 via 192.168.1.1 dev eth0:1 src 192.168.1.4
EOF
$ sudo ifup eth0:1

Check with ip route list that the routing is as intended. A final check that the metering is working as expected is also highly recommended (if things don't behave, tcpdump is your friend, as ever...). Finally reboot the box a couple of times to ensure the IP assignment works across.