WireGuard will always create a virtual interface (wg0), that will behave as a normal linux interface. Because of that, WireGuard is an Route-based VPN.
This interface will work as entry/exit point for encrypted traffic. Traffic is:
1. Routed to wg0;
2. Encrypted;
3. Sent to peer endpoint.
Policy-Based IPsec
This is the default behavior when no Virtual Tunnel Interface (VTI) is used.
Traffic is controlled through kernel IPsec policies (xfrm subsystem)
Traffic is identified using subnet definitions:
Left Subnet: 10.10.10.0/24
Right Subnet: 20.20.20.0/24
With that, kernel creates rules such as:
Source 10.10.10.0/24 AND Destination 20.20.20.0/24 → Encrypt
Before the packet is transmitted, the kernel intercepts it and applies IPsec encryption based on the policy.
Route-Based IPsec (VTI)
When the Virtual Tunnel Interface (VTI) option is enabled, IPsec behaves as a route-based VPN, creating an standard routed interface.
With an configuration like this:
Local Address: 10.10.10.1/30 (Left Address)
Remote Address: 10.10.10.2/30 (Right Address)
This creates a point-to-point logical tunnel between both endpoints. 10.10.10.1/30 would be the VTI IP Address.
The kernel applies IPsec encryption to traffic exiting the interface.
When the option "Automatically create VTI routes" is enabled, routes are installed such as:
20.20.20.0/24 dev vti1
This is based on the networks added as "Subnets" on the Right side.
This ensures that traffic destined for the remote network is sent through the tunnel.
Routing protocols are responsible for dynamically learning, selecting, and installing routes into the Linux routing table. In Nodegrid, these protocols are implemented by FRR and operate on top of the Linux kernel routing system.
Although BGP and OSPF use their own logic to select the “best path”, the final forwarding decision is always performed by the Linux kernel after routes are installed.
Routing protocols calculate the best path internally and then install routes into the kernel routing table.
Example:
20.20.20.0/24 via 10.10.10.2 dev eth0 proto bgp metric 20
From this point forward:
The route behaves like any other route (static or connected);
The kernel is responsible for forwarding packets;
Routing protocol decisions no longer participate in packet forwarding.
The kernel does not consider AS_PATH, OSPF cost or BGP attributes to select the routes.
Route Preference and Priority (Critical Concept)
Different route types have implicit priorities in Linux. Typical order of preference:
Connected routes (highest priority);
Static routes;
Dynamic routes (BGP, OSPF).
Example:
10.10.10.0/24 dev eth0 proto kernel
10.10.10.0/24 via 10.10.10.2 proto bgp
The kernel will always prefer the connected route, regardless of BGP attributes.
Connected routes are automatically created when an interface has an IP address:
10.10.10.0/24 dev eth0 proto kernel scope link
These routes have very high priority and affect routing protocol behavior:
In OSPF:
Connected routes are advertised automatically (depending on configuration)
OSPF uses interface cost to calculate path selection
If a network is directly connected, OSPF prefers it over learned routes
In BGP:
Connected routes can be redistributed into BGP
Local routes often have higher preference (LOCAL_PREF)
Even if BGP advertises an alternative path, the kernel may still prefer the connected route
Protocol Metrics:
OSPF: cost (based on bandwidth).
BGP: attributes (AS_PATH, LOCAL_PREF, MED).
These are used only to decide which route will be installed in the kernel.
If two routes have the same prefix length, the kernel selects the one with the lowest metric.
OSPF Route Selection Behavior
OSPF uses the Shortest Path First algorithm.
Selection is based on:
Sum of interface costs along the path
Example:
Path A cost: 10
Path B cost: 20
OSPF selects Path A and installs it in the kernel.
Once installed:
The kernel uses it like any other route
Only kernel metric matters if multiple equal routes exist
BGP Route Selection Behavior
BGP uses a multi-step decision process:
Highest LOCAL_PREF
Shortest AS_PATH
Lowest MED
eBGP over iBGP
Lowest IGP cost to next hop
After the decision:
Only the best path is installed in the routing table (by default)
Interaction with VPN Interfaces
Routing protocols can run over:
WireGuard interfaces (wg0)
VTI interfaces (vti1)
In these cases:
The tunnel interface appears as a normal interface
OSPF and BGP treat it like any other link
Tunnel IPs are used as next-hop