netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Try NetBox Cloud free: https://netboxlabs.com/free-netbox-cloud/
http://netboxlabs.com/oss/netbox/
Apache License 2.0
15.77k stars 2.54k forks source link

Multiple ASNs per Site #6732

Closed florianschendel closed 2 years ago

florianschendel commented 3 years ago

NetBox version

v2.11.9

Feature type

Change to existing functionality

Proposed functionality

Use case

We use the sites (geographic sites) to document our ASNs that we use. If we have multiple ASNs per site we get a problem.

We want assign multiple ASNs per site e.g. site --> subsidiary-vienna (ASNs: 55555, 66666) small site without DC, no locations.

We want to pin multiple ASNs to locations e. g. site--> datacenter-Munich, location --> mu1 (ASNs: 11111, 22222), location --> mu2 (ASNs: 33333, 44444)

Database changes

No response

External dependencies

No response

jeremystretch commented 3 years ago

This was originally raised in #127 (a very old issue) but never really fleshed out. It's worth revisiting, however we should try to focus on what an ASN model would look like and the relationship(s) to it from other models, as well as a migration strategy to move away from the current approach.

eronlloyd commented 3 years ago

We have equipment in datacenters where we interface with other service providers in a PoP. I wonder if ASNs should instead be linked to the organization, not the sites, as it's currently very restrictive. This seems more natural, and you could even have nested tenants, since we have customers we peer with that have different divisions but all share the same ASNs.

dteknet commented 3 years ago

I would love to have some kind of ASN inventory view where I could manage utilized/free AS numbers. It's useful for clos network topologies, where a lot of ASN are used.

ljb2of3 commented 3 years ago

@eronlloyd FWIW my campus design depends entirely on sites being assigned ASNs. I represent each building as a site. I run eBGP (with private ASNs) between our campus core and each building with EVPN/VXLAN on top. Assigning ASNs only to orgs would break everything I've spent the last year implementing.

There are a few limited cases where one ASN per site has been limiting though. Due to various technical reasons I may have two different ASNs in a single building, which broke my automation model. For the time being I have created dummy sites to represent the weird edge cases, but that's going to complicate things since I won't be able to correctly represent physical equipment in the racks assigned to the site for those edge cases.

I wonder if it would useful be possible to treat ASNs as something that could be inherited, just like Tenants. I'm imagining querying the API for the ASN of a particular device. If it's set on the device I get that back, if not, I get the ASN of the rack the device is in, if that's not assigned I get the ASN of the site. Or maybe I just need to query each level up as desired until I find an ASN. That would let me represent the unique ASN for the oddball device that's in the rack with everything, but every other device in the rack just inherits the site's ASN.

@dteknet I agree. I'm currently tracking all my private ASN usage in a spreadsheet. Not very netbox like! 😄

eronlloyd commented 3 years ago

Thinking simply, why should ASNs be assigned to sites at all? Shouldn't they just be assigned to prefixes, which in real life is where they exist? Prefixes are then assigned to tenants, and tenants to everything else. When an IP is assigned to an interface, then you can see the ASN and traverse the object tree from there. Am I missing something fundamental?

DanSheps commented 3 years ago

I think it would make more sense to pull ASNs out into their own model and allow attaching them to the organizational models (Region, Site, Site Group, Location, Rack, etc).

However, it also might make more sense to make this part of a BGP or other configuration plugin.

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our contributing guide.

jeremystretch commented 2 years ago

Tagging this as needs milestone with the assumption that we'll be introducing a new ASN model.

DanSheps commented 2 years ago

Here is the proposed data model:

class ASN(PrimaryModel):
    asn = INTEGER
    site = ManyToMany(to='dcim.Site', related_name='asns')
    tenant = ForeignKey(to='tenancy.Tenant', related_name='asns', on_delete=PROTECT, blank=True, null=True)
    rir = ForeignKey(to='ipam.RIR', related_name='asns', on_delete=PROTECT, blank=False, null=False)

Please comment on the data model and feel free to make suggestions. Custom Fields could be added, however it may be best to limit the scope for now.

Unfortunately there are a number of other associations we could make (devices for example), however these are best handled within a BGP plugin and not as part of the core netbox functionality.

jmanteau commented 2 years ago

Unfortunately there are a number of other associations we could make (devices for example), however these are best handled within a BGP plugin and not as part of the core netbox functionality.

I disagree with this statement as modelling EVPN with an ASN per device is quite common and this feature would have been interesting to add. However a custom field / plugin can also indeed be done.