Traffic selectors (TS) define which source and destination IP addresses, protocols, and ports are protected by an IPsec CHILD_SA. When the kernel has a matching IPsec policy installed, packets that fall within the traffic selector are encrypted (or processed according to the policy mode) before being forwarded.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/strongswan/strongswan/llms.txt
Use this file to discover all available pages before exploring further.
How traffic selectors work
During IKEv2CREATE_CHILD_SA negotiation, both peers propose traffic selectors. The responder can narrow the proposed selectors — accepting only a subset of what the initiator proposed — but it cannot widen them. The final, negotiated selectors are what get installed as kernel IPsec policies.
For example, if the initiator proposes 0.0.0.0/0 (all traffic) and the responder has local_ts = 10.0.0.0/8, the responder narrows the selector to 10.0.0.0/8. Only traffic destined for 10.0.0.0/8 flows through the tunnel.
Configuration
Traffic selectors are set per CHILD_SA in thechildren section of swanctl.conf:
| Option | Default | Description |
|---|---|---|
local_ts | dynamic | Comma-separated list of local selectors (subnets, addresses, or dynamic) |
remote_ts | dynamic | Comma-separated list of remote selectors |
Selector syntax
Subnets and addresses
Protocol and port restriction
Append a selector in square brackets to restrict by protocol and/or port:tcp, udp, icmp, ipv6-icmp) or by number. Ports can be numeric or a service name resolved via getservent(3). Port ranges are accepted in the configuration syntax, though current Linux kernel XFRM backends do not support port ranges.
For ICMP, specifying a port value less than 256 is interpreted as the ICMP type. A value of 256 or greater is interpreted as type (high byte) and code (low byte) combined.
Multiple selectors
Comma-separate multiple selectors to match traffic from or to several subnets in a single CHILD_SA:%dynamic
The special value %dynamic is a placeholder that is replaced at runtime by the tunnel outer address, or by the virtual IP if one has been negotiated. This is the default for both local_ts and remote_ts.
Use %dynamic on roadwarrior clients so the traffic selector tracks whatever virtual IP the gateway assigns:
Traffic selector narrowing
TS narrowing allows a responder to accept a connection that proposes a wide selector while installing a narrower policy. This is commonly used on gateways serving roadwarriors:- Client proposes
remote_ts = 0.0.0.0/0 - Gateway has
local_ts = 10.0.0.0/8 - Gateway narrows: only
10.0.0.0/8is installed in the kernel
Policy modes
Themode option in a children section controls what the IPsec policy does with matched traffic:
| Mode | Description |
|---|---|
tunnel (default) | Encrypt in IPsec Tunnel Mode — adds outer IP header |
transport | Encrypt in IPsec Transport Mode — protects original IP payload only |
pass | Bypass policy — allow matching traffic to flow in plaintext |
drop | Block policy — drop matching traffic |
Bypass policies
A bypass policy (mode = pass) installs a shunt that explicitly excludes traffic from IPsec processing. This is useful when you have a broad drop policy but need to allow specific local traffic (for example, IKE itself or a management network):
Common patterns
Tunnel all client traffic (split tunneling off)
Split tunneling (corporate subnet only)
Site-to-site with specific subnets
L2TP over IPsec (transport mode)
Checking installed policies
After a CHILD_SA is established, verify the installed traffic selectors:ip xfrm policy (Linux):