A connection between the subnets behind the gateways moon and sun is set up using XFRM interfaces.

The gateways use route-based forwarding with XFRM interfaces, with firewall rules to allow traffic to pass. The IPsec traffic selector used is 0.0.0.0/0, however, specific routing is achieved with routes on the XFRM interfaces. The IKE daemon does not install routes for CHILD_SAs with outbound interface ID, so static routes are installed for the target subnets.

Both gateways use separate interfaces for in- and outbound traffic (which is completely optional and mainly for testing purposes, a single interface will usually be enough). Gateway moon creates them before initiating the connection, while gateway sun dynamically creates the interfaces via updown script using the passed unique generated interface IDs.

Client alice behind gateway moon pings client bob located behind gateway sun.