/testing/guestbin/swan-prep --hostkeys
Creating NSS database containing host keys
west #
 # confirm that the network is alive
west #
 ../../guestbin/wait-until-alive -I 192.0.1.254 192.0.2.254
destination -I 192.0.1.254 192.0.2.254 is alive
west #
 ipsec start
Redirecting to: [initsystem]
west #
 ../../guestbin/wait-until-pluto-started
west #
 ipsec auto --add westnet-eastnet-ikev2
"westnet-eastnet-ikev2": added IKEv2 connection
west #
 echo "initdone"
initdone
west #
 # show nflog global ipsec-all rules
west #
 nft list ruleset
table inet ipsec-log {
	chain input {
		type filter hook input priority filter; policy accept;
		meta ipsec exists log prefix "all-ipsec-input" group 50
	}
	chain output {
		type filter hook output priority filter; policy accept;
		rt ipsec exists log prefix "all-ipsec-output" group 50
	}
}
west #
 ipsec auto --up westnet-eastnet-ikev2
"westnet-eastnet-ikev2" #1: initiating IKEv2 connection to 192.1.2.23 using UDP
"westnet-eastnet-ikev2" #1: sent IKE_SA_INIT request to 192.1.2.23:UDP/500
"westnet-eastnet-ikev2" #1: processed IKE_SA_INIT response from 192.1.2.23:UDP/500 {cipher=AES_GCM_16_256 integ=n/a prf=HMAC_SHA2_512 group=DH19}, initiating IKE_AUTH
"westnet-eastnet-ikev2" #1: sent IKE_AUTH request to 192.1.2.23:UDP/500
"westnet-eastnet-ikev2" #1: initiator established IKE SA; authenticated peer using preloaded certificate '@east' and 2nnn-bit RSASSA-PSS with SHA2_512 digital signature
"westnet-eastnet-ikev2" #2: initiator established Child SA using #1; IPsec tunnel [192.0.1.0/24===192.0.2.0/24] {ESP/ESN=>0xESPESP <0xESPESP xfrm=AES_GCM_16_256-NONE DPD=passive}
west #
 # suppress job monitoring; specify packet count
west #
 rm -f /tmp/nflog-50.pcap /tmp/tcpdump.log
west #
 set +m
west #
 tcpdump -c 4 -s 0 -w /tmp/nflog-50.pcap -i nflog:50 > /tmp/tcpdump.log 2>&1 & sleep 1
[x] PID
west #
 ../../guestbin/wait-for.sh --match 'listening on' -- cat /tmp/tcpdump.log
tcpdump: listening on INTERFACE DETAILS
west #
 ../../guestbin/ping-once.sh --up -I 192.0.1.254 192.0.2.254
up
west #
 ../../guestbin/ping-once.sh --up -I 192.0.1.254 192.0.2.254
up
west #
 # wait for count to reach tcpdump then dump it
west #
 wait
west #
 cp  /tmp/nflog-50.pcap OUTPUT/nflog-50.pcap
west #
 tcpdump -n -r OUTPUT/nflog-50.pcap 2>/dev/null
IP 192.0.1.254 > 192.0.2.254: ICMP echo request, id XXXX, seq 1, length 64
IP 192.0.2.254 > 192.0.1.254: ICMP echo reply, id XXXX, seq 1, length 64
IP 192.0.1.254 > 192.0.2.254: ICMP echo request, id XXXX, seq 1, length 64
IP 192.0.2.254 > 192.0.1.254: ICMP echo reply, id XXXX, seq 1, length 64
west #
 echo done
done
west #
 ../../guestbin/ipsec-kernel-state.sh
west #
 ../../guestbin/ipsec-kernel-policy.sh
src 192.0.1.0/24 dst 192.0.2.0/24
	dir out action block priority PRIORITY ptype main
	tmpl src 0.0.0.0 dst 0.0.0.0
		proto esp reqid 0 mode transport
west #
 nft list ruleset
table inet ipsec-log {
	chain input {
		type filter hook input priority filter; policy accept;
		meta ipsec exists log prefix "all-ipsec-input" group 50
	}
	chain output {
		type filter hook output priority filter; policy accept;
		rt ipsec exists log prefix "all-ipsec-output" group 50
	}
}
west #
 ipsec stop
Redirecting to: [initsystem]
west #
 # show no nflog left behind
west #
 # it may leave an empty table ip filter
west #
 nft list ruleset
west #
 
