IP-XFRM(8)
๐ IP-XFRM(8) ๐
okay bestie, this is the ip-xfrm page, and it's literally transform configuration. We're in part 1, so let's vibe.
โจ NAME โจ
ip-xfrm โ transform configuration
๐ธ SYNOPSIS ๐ธ
okay so the whole thing kicks off like this:
ip [ OPTIONS ] xfrm { COMMAND | help }
ip xfrm XFRM-OBJECT { COMMAND | help }
XFRM-OBJECT := state | policy | monitor
๐ฆ state ๐ฆ
here's the state command menu, no cap:
state commands
ip xfrm state { add | update } ID [ ALGO-LIST ] [ mode MODE ] [ mark
MARK [ mask MASK ] ] [ reqid REQID ] [ dir SA-DIR ] [ seq SEQ ]
[ replay-window SIZE ] [ replay-seq SEQ ] [ replay-oseq SEQ ] [
replay-seq-hi SEQ ] [ replay-oseq-hi SEQ ] [ flag FLAG-LIST ] [
sel SELECTOR ] [ LIMIT-LIST ] [ encap ENCAP ] [ coa ADDR[/PLEN]
] [ ctx CTX ] [ extra-flag EXTRA-FLAG-LIST ] [ output-mark
OUTPUT-MARK [ mask MASK ] ] [ if_id IF-ID ] [ offload [
crypto|packet ] dev DEV dir DIR ] [ tfcpad LENGTH ] [ pcpu-num
CPUNUM ]
ip xfrm state allocspi ID [ mode MODE ] [ mark MARK [ mask MASK ] ] [
reqid REQID ] [ seq SEQ ] [ min SPI max SPI ] [ pcpu-num CPUNUM
]
ip xfrm state { delete | get } ID [ mark MARK [ mask MASK ] ]
ip [ -4 | -6 ] xfrm state deleteall [ ID ] [ mode MODE ] [ reqid REQID ]
[ flag FLAG-LIST ]
ip [ -4 | -6 ] xfrm state list [ ID ] [ nokeys ] [ mode MODE ] [ reqid
REQID ] [ flag FLAG-LIST ]
ip xfrm state flush [ proto XFRM-PROTO ]
ip xfrm state count
state definitions
and the state building blocks are:
ID := [ src ADDR ] [ dst ADDR ] [ proto XFRM-PROTO ] [ spi SPI ]
XFRM-PROTO := esp | ah | comp | route2 | hao
ALGO-LIST := [ ALGO-LIST ] ALGO
ALGO := { enc | auth } ALGO-NAME ALGO-KEYMAT |
auth-trunc ALGO-NAME ALGO-KEYMAT ALGO-TRUNC-LEN |
aead ALGO-NAME ALGO-KEYMAT ALGO-ICV-LEN |
comp ALGO-NAME
MODE := transport | tunnel | beet | ro | in_trigger
SA-DIR := in | out
FLAG-LIST := [ FLAG-LIST ] FLAG
FLAG := noecn | decap-dscp | nopmtudisc | wildrecv | icmp | af-unspec |
align4 | esn
SELECTOR := [ src ADDR[/PLEN] ] [ dst ADDR[/PLEN] ] [ dev DEV ]
[ UPSPEC ]
UPSPEC := proto { PROTO |
{ tcp | udp | sctp | dccp } [ sport PORT ] [ dport PORT ] |
{ icmp | ipv6-icmp | mobility-header } [ type NUMBER ] [ code
NUMBER ] |
gre [ key { DOTTED-QUAD | NUMBER } ] }
LIMIT-LIST := [ LIMIT-LIST ] limit LIMIT
LIMIT := { time-soft | time-hard | time-use-soft | time-use-hard }
SECONDS |
{ byte-soft | byte-hard } SIZE |
{ packet-soft | packet-hard } COUNT
ENCAP := { espinudp | espinudp-nonike | espintcp } SPORT DPORT OADDR
EXTRA-FLAG-LIST := [ EXTRA-FLAG-LIST ] EXTRA-FLAG
EXTRA-FLAG := dont-encap-dscp | oseq-may-wrap
๐ policy ๐
next, policy is serving commands too:
policy commands
ip xfrm policy { add | update } SELECTOR dir DIR [ ctx CTX ] [ mark MARK
[ mask MASK ] ] [ index INDEX ] [ ptype PTYPE ] [ action ACTION
] [ priority PRIORITY ] [ flag FLAG-LIST ] [ if_id IF-ID ] [
offload packet dev DEV ] [ LIMIT-LIST ] [ TMPL-LIST ]
ip xfrm policy { delete | get } { SELECTOR | index INDEX } dir DIR [ ctx
CTX ] [ mark MARK [ mask MASK ] ] [ ptype PTYPE ] [ if_id IF-ID
]
ip [ -4 | -6 ] xfrm policy { deleteall | list } [ nosock ] [ SELECTOR ]
[ dir DIR ] [ index INDEX ] [ ptype PTYPE ] [ action ACTION ] [
priority PRIORITY ] [ flag FLAG-LIST]
ip xfrm policy flush [ ptype PTYPE ]
ip xfrm policy count
ip xfrm policy set [ hthresh4 LBITS RBITS ] [ hthresh6 LBITS RBITS ]
ip xfrm policy setdefault DIR ACTION [ DIR ACTION ] [ DIR ACTION ]
ip xfrm policy getdefault
policy definitions
and the policy building blocks:
SELECTOR := [ src ADDR[/PLEN] ] [ dst ADDR[/PLEN] ] [ dev DEV ] [ UPSPEC
]
UPSPEC := proto { PROTO |
{ tcp | udp | sctp | dccp } [ sport PORT ] [ dport PORT ] |
{ icmp | ipv6-icmp | mobility-header } [ type NUMBER ] [ code
NUMBER ] |
gre [ key { DOTTED-QUAD | NUMBER } ] }
DIR := in | out | fwd
PTYPE := main | sub
ACTION := allow | block
FLAG-LIST := [ FLAG-LIST ] FLAG
FLAG := localok | icmp
LIMIT-LIST := [ LIMIT-LIST ] limit LIMIT
LIMIT := { time-soft | time-hard | time-use-soft | time-use-hard }
SECONDS |
{ byte-soft | byte-hard } SIZE |
{ packet-soft | packet-hard } COUNT
TMPL-LIST := [ TMPL-LIST ] tmpl TMPL
TMPL := ID [ mode MODE ] [ reqid REQID ] [ level LEVEL ]
ID := [ src ADDR ] [ dst ADDR ] [ proto XFRM-PROTO ] [ spi SPI ]
XFRM-PROTO := esp | ah | comp | route2 | hao
MODE := transport | tunnel | beet | ro | in_trigger
LEVEL := required | use
๐ monitor ๐
finally, monitor is the watch vibe:
ip xfrm monitor [ all-nsid ] [ nokeys ] [ all
| LISTofXFRM-OBJECTS ]
LISTofXFRM-OBJECTS := [ LISTofXFRM-OBJECTS ] XFRM-OBJECT
XFRM-OBJECT := acquire | expire | SA | policy | aevent | report
โจ DESCRIPTION โจ
okay so bestie, xfrm is an IP framework for transforming packets (think encrypting their payloads, that whole situation). This framework is what implements the IPsec protocol suite โ the state object works on the Security Association Database, and the policy object works on the Security Policy Database. It's ALSO used for the IP Payload Compression Protocol and for features of Mobile IPv6. multi-purpose queen fr fr ๐
Here's the state command lineup, no cap:
ip xfrm state add add new state into xfrm
ip xfrm state update update existing state in xfrm
ip xfrm state allocspi allocate an SPI value
ip xfrm state delete delete existing state in xfrm
ip xfrm state get get existing state in xfrm
ip xfrm state deleteall delete all existing state in xfrm
ip xfrm state list print out the list of existing state in xfrm
ip xfrm state flush flush all state in xfrm
ip xfrm state count count all existing state in xfrm
Now the vocabulary you're gonna keep seeing, bestie โ learn these and you're golden โจ
IDโ is specified by a source address, destination address, transform protocolXFRM-PROTO, and/or Security Parameter IndexSPI. (For IP Payload Compression, the Compression Parameter Index orCPIis used forSPI.)XFRM-PROTOโ specifies a transform protocol: IPsec Encapsulating Security Payload (esp), IPsec Authentication Header (ah), IP Payload Compression (comp), Mobile IPv6 Type 2 Routing Header (route2), or Mobile IPv6 Home Address Option (hao).ALGO-LISTโ contains one or more algorithms to use. Each algorithmALGOis specified by:- the algorithm type: encryption (
enc), authentication (authorauth-trunc), authenticated encryption with associated data (aead), or compression (comp) - the algorithm name
ALGO-NAME(see below) - (for all except
comp) the keying materialALGO-KEYMAT, which may include both a key and a salt or nonce value; refer to the corresponding RFC - (for
auth-trunconly) the truncation lengthALGO-TRUNC-LENin bits - (for
aeadonly) the Integrity Check Value lengthALGO-ICV-LENin bits
- the algorithm type: encryption (
Encryption algorithms include ecb(cipher_null), cbc(des), cbc(des3_ede), cbc(cast5), cbc(blowfish), cbc(aes), cbc(serpent), cbc(camellia), cbc(twofish), and rfc3686(ctr(aes)).
Authentication algorithms include digest_null, hmac(md5), hmac(sha1), hmac(sha256), hmac(sha384), hmac(sha512), hmac(rmd160), and xcbc(aes).
Authenticated encryption with associated data (AEAD) algorithms include rfc4106(gcm(aes)), rfc4309(ccm(aes)), and rfc4543(gcm(aes)).
Compression algorithms include deflate, lzs, and lzjh.
MODEโ specifies a mode of operation for the transform protocol. IPsec and IP Payload Compression modes aretransport,tunnel, and (for IPsec ESP only) Bound End-to-End Tunnel (beet). Mobile IPv6 modes are route optimization (ro) and inbound trigger (in_trigger).FLAG-LISTโ contains one or more of the following optional flags:noecn,decap-dscp,nopmtudisc,wildrecv,icmp,af-unspec,align4, oresn.SELECTORโ selects the traffic that will be controlled by the policy, based on the source address, the destination address, the network device, and/orUPSPEC.UPSPECโ selects traffic by protocol. For thetcp,udp,sctp, ordccpprotocols, the source and destination port can optionally be specified. For theicmp,ipv6-icmp, ormobility-headerprotocols, the type and code numbers can optionally be specified. For thegreprotocol, the key can optionally be specified as a dotted-quad or number. Other protocols can be selected by name or numberPROTO.LIMIT-LISTโ sets limits in seconds, bytes, or numbers of packets.ENCAPโ encapsulates packets with protocolespinudp,espinudp-nonike, orespintcp, using source portSPORT, destination portDPORT, and original addressOADDR.MARKโ used to match xfrm policies and statesOUTPUT-MARKโ used to set the output mark to influence the routing of the packets emitted by the stateIF-IDโ xfrm interface identifier used to in both xfrm policies and statesDEVโ Network interface name used to offload policies and states
๐ the policy side of things ๐
policies are their own whole vibe, so here's the roster:
ip xfrm policy add add a new policy
ip xfrm policy update update an existing policy
ip xfrm policy delete delete an existing policy
ip xfrm policy get get an existing policy
ip xfrm policy deleteall delete all existing xfrm policies
ip xfrm policy list print out the list of xfrm policies
ip xfrm policy flush flush policies
nosockโ filter (remove) all socket policies from the output.
And the policy dictionary, bestie:
SELECTORโ selects the traffic that will be controlled by the policy, based on the source address, the destination address, the network device, and/orUPSPEC.UPSPECโ selects traffic by protocol. For thetcp,udp,sctp, ordccpprotocols, the source and destination port can optionally be specified. For theicmp,ipv6-icmp, ormobility-headerprotocols, the type and code numbers can optionally be specified. For thegreprotocol, the key can optionally be specified as a dotted-quad or number. Other protocols can be selected by name or numberPROTO.DIRโ selects the policy direction asin,out, orfwd.CTXโ sets the security context.PTYPEโ can bemain(default) orsub.ACTIONโ can beallow(default) orblock.PRIORITYโ is a number that defaults to zero.FLAG-LISTโ contains one or both of the following optional flags:localoricmp.LIMIT-LISTโ sets limits in seconds, bytes, or numbers of packets.TMPL-LISTโ is a template list specified usingID,MODE,REQID, and/orLEVEL.IDโ is specified by a source address, destination address, transform protocolXFRM-PROTO, and/or Security Parameter IndexSPI. (For IP Payload Compression, the Compression Parameter Index orCPIis used forSPI.)XFRM-PROTOโ specifies a transform protocol: IPsec Encapsulating Security Payload (esp), IPsec Authentication Header (ah), IP Payload Compression (comp), Mobile IPv6 Type 2 Routing Header (route2), or Mobile IPv6 Home Address Option (hao).MODEโ specifies a mode of operation for the transform protocol. IPsec and IP Payload Compression modes aretransport,tunnel, and (for IPsec ESP only) Bound End-to-End Tunnel (beet). Mobile IPv6 modes are route optimization (ro) and inbound trigger (in_trigger).LEVELโ can berequired(default) oruse.
counting, hashing & monitoring ๐
ip xfrm policy count โ count existing policies
Use one or more -s options to display more details, including policy hash table information.
ip xfrm policy set โ configure the policy hash table
Security policies whose address prefix lengths are greater than or equal policy hash table thresholds are hashed. Others are stored in the policy_inexact chained list.
LBITSโ specifies the minimum local address prefix length of policies that are stored in the Security Policy Database hash table.RBITSโ specifies the minimum remote address prefix length of policies that are stored in the Security Policy Database hash table.
ip xfrm monitor โ state monitoring for xfrm objects
The xfrm objects to monitor can be optionally specified.
If the all-nsid option is set, the program listens to all network namespaces that have a nsid assigned into the network namespace were the program is running. A prefix is displayed to show the network namespace where the message originates. Example:
[nsid 1]Flushed state proto 0
๐ AUTHOR ๐
Manpage revised by David Ward <david.ward@ll.mit.edu> Manpage revised by Christophe Gouault <christophe.gouault@6wind.com> Manpage revised by Nicolas Dichtel <nicolas.dichtel@6wind.com>
and that's a wrap, bestie!! ๐ซถ this iconic little page lives in iproute2 and its date is 20 Dec 2011 โ yes it's been serving looks since way back, and it's still IP-XFRM(8) through and through. go configure something gorgeous ๐
โจ
๐ฆ where this page comes from
- alpine 3.24: iproute2-doc 7.0.0-r0 ยท GPL-2.0-or-later
- arch rolling: iproute2 7.2.0-1
- arch rolling: iproute2 7.3.0-1 ยท GPL-2.0-or-later
- centos-stream 10: iproute 7.0.0-2.el10 ยท GPL-2.0-or-later AND NIST-PD
- nixos 26.05: iproute2 7.0.0
- nixpkgs unstable: iproute2 7.2.0
- ubuntu resolute: iproute2 6.19.0-1ubuntu1 ยท GPL-2.0-only
- ubuntu resolute: iproute2 6.19.0-1ubuntu1.1 ยท GPL-2.0-only
- ubuntu stonking: iproute2 7.2.0-1ubuntu1 ยท GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms