NL-ix / bird-stack

BIRD-Stack: StackStorm based framework for BIRD route-server configuration
GNU General Public License v3.0
8 stars 3 forks source link

St2 bird: IPv6 communities generation #4

Open diellenne opened 6 years ago

diellenne commented 6 years ago

At the moment BIRD-Stack has a function to generate an integer representation of IPs

def int_ipv4(ipv4_address, network):
    octets = ipv4_address.split(".")
    diff = int(network.split(".")[2])
    o3 = str(int(octets[2]) - diff)
    o4 = str(octets[3])
    if len(o4) < 3:
        o4 = ("0" * (3 - len(o4))) + o4
    return o3 + o4

The result is used to define a community string, identifying uniquely that specific IP address, and this community string can be used to implement specific IPs filtering.

At the moment this approach just works for IPv4 and for this reason we will need the related IPv4 addresses also when we are defining IPv6 configurations.

Would be nice to find a generation algorithm that will work also for IPv6.

job commented 6 years ago

If you use BGP Large Communities, you can just put the last 32 bits of the IPv6 address in the third 32-bit field of a large community. You can use the second field of large communities to indicate that what follows is the epilogue of an ipv6 address.

This way you don't need to do magic, and no chance of collision (given nl-ix's ipv6 numbering plan)