(First some notes that are easier to understand than the horrible mess of EBNF that ip xfrm spits out)
The command line for XFRM is:
ip xfrm policy add SELECTOR dir DIR [LIMITS] [TEMPLATES]
Now SELECTOR matches on a packet, it can be any sensible combination of:
src ADDRsrc ADDR/PREFIXLENdst ADDRdst ADDR/PREFIXLENdev DEVICEproto { tcp | udp | sctp | dccp } [sport PORT] [dport PORT]proto { icmp | icmp6-icmp | mobility-header } [type NUMBER] [code NUMBER]proto gre [key { DOTTED-QUAD | NUMBER } ]proto PROTOFor example SELECTOR might be:
src 10.1.0.0/16 dst 10.2.0.0/16 dev eth0 proto tcp port 80
DIR can be one of:
inoutfwdLIMITS can be any sensible combination of:
time-soft SECONDStime-hard SECONDStime-use-soft SECONDStime-use-hard SECONDSbyte-soft SIZEbyte-hard SIZEpacket-soft COUNTpacket-hard COUNTThis appears to be some kind of rate limiting functionality?
TEMPLATES consist of a list of the word tmpl and any sensible combination of:
src ADDRdst ADDRproto [ esp | ah | comp | route2 | hao ]
These correspond to:
esp - IPSec Encapsulating Security Protocolah - IPSec Authentication Headercomp - IP Payload Compression.route2 - Mobile IPv6 Type 2 Routing Header.spi SPIthen they have an optional MODE which can be one of:
mode transport (IPSec transport mode)mode tunnel (IPSec tunnel mode)mode ro (Route Optimisation)mode in\_trigger ("inbound trigger")mode beet (Bound End-to-End Tunnel)This can then be optionally flagged as "level required" (default) or
"level use"
These TEMPLATES seem to specify what to do with the packet.
So, an (untested) sample command line might be:
ip xfrm \
policy add \
src 10.1.0.0/16 dst 10.2.0.0/16 proto icmp \
dir out \
tmpl proto route2 dst 10.3.0.1 mode ro level use
ip xfrm \
state add \
src 10.1.0.0/16 dst 10.2.0.0/16 proto icmp \
proto route2 mode ro \
coa 10.3.0.1 \
sel src ::/0 dst ::/0
I don't know what the "xfrm state" sel is used for. It's a selector for something, but I dunno why it doesn't just match on the src/dst earlier in the command line. Oh, it's used for the outer addresses on encap tunnels?
index