# BGP Communities

> **AS203314 BGP Communities**
>
> Hats Network (AS203314) uses a **comprehensive BGP community structure** to help network operators manage their routing policies effectively.

## Community System Overview

## Quick Reference

| Category            | Community        | Purpose                   | Details                                                                               |
| ------------------- | ---------------- | ------------------------- | ------------------------------------------------------------------------------------- |
| **Origin**          | `203314:110:XX`  | Route source type         | [See Origin →](/docs/community/internal-communities#route-origin)                     |
| **PoP**             | `203314:120:XXX` | Learned at PoP            | [See PoP-Based →](/docs/community/internal-communities#pop-based-communities)         |
| **PoP Pass**        | `203314:125:XXX` | Passed through PoP        | [See PoP-Based →](/docs/community/internal-communities#pop-based-communities)         |
| **Region**          | `203314:130:XX`  | Learned in region         | [See Region-Based →](/docs/community/internal-communities#region-based-communities)   |
| **Region Pass**     | `203314:135:XX`  | Passed through region     | [See Region-Based →](/docs/community/internal-communities#region-based-communities)   |
| **Blackhole**       | `203314:0:666`   | Do not announce           | [See Blackhole →](/docs/community/control-communities#blackhole--filtering)           |
| **No Upstream**     | `203314:1:0`     | Do not send to upstream   | [See Propagation →](/docs/community/control-communities#propagation-control)          |
| **No Peering**      | `203314:1:1`     | Do not send to peering    | [See Propagation →](/docs/community/control-communities#propagation-control)          |
| **No Customer**     | `203314:1:2`     | Do not send to downstream | [See Propagation →](/docs/community/control-communities#propagation-control)          |
| **No Cross-Region** | `203314:2:1`     | Keep within region        | [See Geo Restrictions →](/docs/community/control-communities#geographic-restrictions) |
| **No Cross-PoP**    | `203314:2:2`     | Keep within PoP           | [See Geo Restrictions →](/docs/community/control-communities#geographic-restrictions) |
| **No Region**       | `203314:201:XX`  | Exclude region            | [See Geo Restrictions →](/docs/community/control-communities#geographic-restrictions) |
| **No PoP**          | `203314:202:XXX` | Exclude PoP               | [See Geo Restrictions →](/docs/community/control-communities#geographic-restrictions) |
| **Prepend 1x**      | `203314:220:1`   | Prepend AS 1 time         | [See Path Prepending →](/docs/community/control-communities#path-prepending)          |
| **Prepend 2x**      | `203314:220:2`   | Prepend AS 2 times        | [See Path Prepending →](/docs/community/control-communities#path-prepending)          |
| **Prepend 3x**      | `203314:220:3`   | Prepend AS 3 times        | [See Path Prepending →](/docs/community/control-communities#path-prepending)          |
| **Prepend 4x**      | `203314:220:4`   | Prepend AS 4 times        | [See Path Prepending →](/docs/community/control-communities#path-prepending)          |
| **Prepend 5x**      | `203314:220:5`   | Prepend AS 5 times        | [See Path Prepending →](/docs/community/control-communities#path-prepending)          |

## Community Categories

- [Internal Communities](/docs/community/internal-communities) — Route origin types, PoP locations, and region codes for identifying where routes are learned.

- [Control Communities](/docs/community/control-communities) — Traffic engineering communities for blackhole, propagation control, and path prepending.

- [PoP Codes](/docs/community/pop-codes) — 3-digit codes for each Point of Presence used in location-based communities.

- [Region Codes](/docs/community/region-codes) — 2-digit geographic region codes for area-based routing policies.

## Usage Examples

> ### Common Scenarios
>
> * Keep traffic local:
>
> ```bird2
> bgp_large_community.add((203314, 2, 1)); # Do not send to other regions
> ```
>
> * Deprioritize upstream:
>
> ```bird2
> bgp_large_community.add((203314, 220, 3)); # Prepend 3x to upstream routes
> ```
>
> * Exclude specific PoP:
>
> ```bird2
> bgp_large_community.add((203314, 202, 253)); # Do not send to AMS
> ```

## Configuration Examples (JunOS / BIRD2)

Below are minimal snippets showing how to **attach AS203314 large communities** to the prefixes you
announce to us.

> **Export Policy Safety Default (Strongly Recommended)**
>
> These snippets are **export policies**. For BIRD2, use `reject;` as the default action to prevent
> route leaks.\
> For JunOS, add a final `term REJECT-ALL then reject` as a safety catch-all.

> **Documentation Prefixes**
>
> These examples use documentation-only prefixes from RFC 5737 / RFC 3849 (e.g. `203.0.113.0/24`,
> `2001:db8::/32`). Replace them with your real announced prefixes.

### Junos

**Keep traffic local (`203314:2:1`)**

```bash
set policy-options community HATS-NO-CROSS-REGION members large:203314:2:1

set policy-options policy-statement EXPORT-TO-HATS term LOCAL from route-filter 203.0.113.0/24 exact
set policy-options policy-statement EXPORT-TO-HATS term LOCAL then community add HATS-NO-CROSS-REGION
set policy-options policy-statement EXPORT-TO-HATS term LOCAL then accept
set policy-options policy-statement EXPORT-TO-HATS term REJECT-ALL then reject
```

**Deprioritize a backup prefix (`203314:220:3`)**

```bash
set policy-options community HATS-PREPEND-3X members large:203314:220:3

set policy-options policy-statement EXPORT-TO-HATS term BACKUP from route-filter 203.0.113.0/24 exact
set policy-options policy-statement EXPORT-TO-HATS term BACKUP then community add HATS-PREPEND-3X
set policy-options policy-statement EXPORT-TO-HATS term BACKUP then accept
set policy-options policy-statement EXPORT-TO-HATS term REJECT-ALL then reject
```

**IPv6 variant**

```bash
set policy-options community HATS-NO-CROSS-REGION members large:203314:2:1

set policy-options policy-statement EXPORT-TO-HATS term LOCAL-V6 from route-filter 2001:db8:203:113::/48 exact
set policy-options policy-statement EXPORT-TO-HATS term LOCAL-V6 then community add HATS-NO-CROSS-REGION
set policy-options policy-statement EXPORT-TO-HATS term LOCAL-V6 then accept
set policy-options policy-statement EXPORT-TO-HATS term REJECT-ALL then reject
```

### Bird2

**Keep traffic local (`203314:2:1`)**

```bird2
filter export_to_hats_v4 {
  if net = 203.0.113.0/24 then {
    bgp_large_community.add((203314, 2, 1));
    accept;
  }
  reject; # Safety default
}
```

**Deprioritize a backup prefix (`203314:220:3`)**

```bird2
filter export_to_hats_v4 {
  if net = 203.0.113.0/24 then {
    bgp_large_community.add((203314, 220, 3));
    accept;
  }
  reject; # Safety default
}
```

**IPv6 variant**

```bird2
filter export_to_hats_v6 {
  if net = 2001:db8:203:113::/48 then {
    bgp_large_community.add((203314, 2, 1));
    accept;
  }
  reject; # Safety default
}
```

## Related Resources

- [Peering Policy](/docs/peering) — Learn how to establish BGP peering with AS203314.

- [IP Transit](/docs/transit) — Get IP-Transit with BGP community support.

---

## License and attribution

- **Canonical source:** [View the human-readable HTML page](https://hatsnet.io/docs/community).
- **Original documentation:** © Hats Network Inc., licensed under [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/).
- **Full terms:** [Content and Data License](https://hatsnet.io/docs/legal/content-and-data-license) — includes attribution requirements, third-party material, trademarks, source code and other exclusions.
