# Peering via Tunnel

Establishing a peering connection with AS203314 via tunnel is useful when physical interconnection is not feasible. We support both Layer 2 and Layer 3 tunneling protocols.

> **When to Use Tunnel Peering**
>
> Tunnel peering is typically used when:
>
> * You're not co-located with us at any IXP or data center
> * Physical cross-connect is not available or cost-prohibitive
> * You need a temporary peering arrangement before establishing physical connectivity
> * You're in a region where we don't have physical presence

## Tunnel Architecture

## Layer 2 vs Layer 3 Tunneling

### L2

**Layer 2 tunnels** encapsulate Ethernet frames, creating a virtual bridge between networks.

**Protocols**: GRETAP, VxLAN

**Use cases**:

* Carrying VLAN-tagged traffic
* Running bridging protocols (STP, LLDP)
* Extending a broadcast domain

**Considerations**: Higher overhead than Layer 3, not suitable for long-distance peering.

[Learn more about Layer 2 tunnels →](/docs/peering/via-layer2-tunnel)

### L3

**Layer 3 tunnels** encapsulate IP packets, operating at the network layer.

**Protocols**: WireGuard, GRE, SIT/ip6gre

**Use cases**:

* Standard BGP peering
* IPv6 transport over IPv4 (6in4)
* Encrypted peering (WireGuard)

**Considerations**: Lower overhead, more efficient for most peering scenarios.

[Learn more about Layer 3 tunnels →](/docs/peering/via-layer3-tunnel)

## Configuration Examples

All tunnel configurations use placeholder values that you'll replace with actual values:

```yaml
# Replace these placeholders with your actual values
your_name: "{tunnel name}"
yourside_ip: "{your public IP}"
ourside_ip: "{our endpoint IP}"
yourside_port: "{your source port (WireGuard)}"
ourside_port: "{our destination port (WireGuard)}"
your_tunnel_ip: "{your tunnel IP address}"
our_tunnel_ip: "{our tunnel IP address}"
tunnel_cidr: "{tunnel subnet CIDR}"
vni: "{VxLAN Network Identifier}"
public_key: "{our WireGuard public key}"
private_key: "{your WireGuard private key}"
```

## Protocol Comparison

| Protocol  | Layer | Encryption | Multi-protocol | Use Case               |
| --------- | ----- | ---------- | -------------- | ---------------------- |
| WireGuard | L3    | Yes        | IPv4/IPv6      | Secure, modern peering |
| GRE       | L3    | No         | IPv4/IPv6      | Simple IP tunneling    |
| GRETAP    | L2    | No         | Ethernet       | Bridging, VLANs        |
| VxLAN     | L2    | No         | Ethernet       | Data center overlay    |
| SIT       | L3    | No         | IPv6-over-IPv4 | 6in4 connectivity      |
| ip6gre    | L3    | No         | IPv6-over-IPv4 | GRE for IPv6           |

- [Layer 2 Tunnels](/docs/peering/via-layer2-tunnel) — GRETAP and VxLAN for Ethernet-layer encapsulation.

- [Layer 3 Tunnels](/docs/peering/via-layer3-tunnel) — WireGuard, GRE, and SIT for IP-layer encapsulation.

## Next Steps

1. Choose the appropriate tunnel type for your use case
2. Follow the configuration examples
3. Contact us to finalize the peering session

> **Need help deciding?**
>
> For most peering scenarios, Layer 3 tunnels (especially WireGuard or GRE) are recommended due to lower overhead and better performance.

---

## License and attribution

- **Canonical source:** [View the human-readable HTML page](https://hatsnet.io/docs/peering/via-tunnel).
- **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.
