/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 #
 # ensure that clear text does not get through
west #
 # ../../guestbin/nftable-westneteastnet-ipsec-only.nft
west #
 # confirm clear text does not get through
west #
 ../../guestbin/ping-once.sh --down -I 192.0.1.254 192.0.2.254
up UNEXPECTED
# ping -n -c 1  -i 2 -w 1   -I 192.0.1.254 192.0.2.254
PING 192.0.2.254 (192.0.2.254) from 192.0.1.254 : 56(84) bytes of data. 64 bytes from 192.0.2.254: icmp_seq=1 ttl=64 time=0.XXX ms --- 192.0.2.254 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time XXXX rtt min/avg/max/mdev = 0.XXX/0.XXX/0.XXX/0.XXX ms
west #
 ipsec start
Redirecting to: [initsystem]
west #
 ../../guestbin/wait-until-pluto-started
west #
 ipsec auto --add westnet-eastnet-nflog
"westnet-eastnet-nflog": added IKEv1 connection
west #
 ipsec auto --add west-east-nflog
"west-east-nflog": added IKEv1 connection
west #
 echo "initdone"
initdone
west #
 nft list ruleset
west #
 ipsec auto --up westnet-eastnet-nflog
"westnet-eastnet-nflog" #1: initiating IKEv1 Main Mode connection
"westnet-eastnet-nflog" #1: sent Main Mode request
"westnet-eastnet-nflog" #1: sent Main Mode I2
"westnet-eastnet-nflog" #1: sent Main Mode I3
"westnet-eastnet-nflog" #1: Peer ID is ID_FQDN: '@east'
"westnet-eastnet-nflog" #1: authenticated peer using preloaded certificate '@east' and 2nnn-bit RSA with SHA1 signature
"westnet-eastnet-nflog" #1: ISAKMP SA established {auth=RSA_SIG cipher=AES_CBC_256 integ=HMAC_SHA2_256 group=MODP2048}
"westnet-eastnet-nflog" #2: initiating Quick Mode IKEv1+RSASIG+ENCRYPT+TUNNEL+PFS+UP+IKE_FRAG_ALLOW+ESN_NO+ESN_YES
"westnet-eastnet-nflog" #2: sent Quick Mode request
"westnet-eastnet-nflog" #2: IPsec SA established tunnel mode {ESP=>0xESPESP <0xESPESP xfrm=AES_CBC_128-HMAC_SHA1_96 DPD=passive}
west #
 nft list ruleset
table inet ipsec-log {
	chain input {
		type filter hook input priority filter; policy accept;
		ipsec in reqid REQID ip saddr 192.0.2.0/24 ip daddr 192.0.1.0/24 counter packets 0 bytes 0 log group 13
	}
	chain output {
		type filter hook output priority filter; policy accept;
		ipsec out reqid REQID ip saddr 192.0.1.0/24 ip daddr 192.0.2.0/24 counter packets 0 bytes 0 log group 13
	}
}
west #
 ipsec auto --up west-east-nflog
"west-east-nflog" #3: initiating Quick Mode IKEv1+RSASIG+ENCRYPT+TUNNEL+PFS+UP+IKE_FRAG_ALLOW+ESN_NO+ESN_YES
"west-east-nflog" #3: sent Quick Mode request
"west-east-nflog" #3: IPsec SA established tunnel mode {ESP=>0xESPESP <0xESPESP xfrm=AES_CBC_128-HMAC_SHA1_96 DPD=passive}
west #
 nft list ruleset
table inet ipsec-log {
	chain input {
		type filter hook input priority filter; policy accept;
		ipsec in reqid REQID ip saddr 192.0.2.0/24 ip daddr 192.0.1.0/24 counter packets 0 bytes 0 log group 13
		ipsec in reqid REQID ip saddr 192.1.2.23 ip daddr 192.1.2.45 counter packets 0 bytes 0 log group 50
	}
	chain output {
		type filter hook output priority filter; policy accept;
		ipsec out reqid REQID ip saddr 192.0.1.0/24 ip daddr 192.0.2.0/24 counter packets 0 bytes 0 log group 13
		ipsec out reqid REQID ip saddr 192.1.2.45 ip daddr 192.1.2.23 counter packets 0 bytes 0 log group 50
	}
}
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.1.2.45 192.1.2.23
up
west #
 ../../guestbin/ping-once.sh --up -I 192.0.1.254 192.0.2.254
up
west #
 ../../guestbin/ping-once.sh --up -I 192.1.2.45 192.1.2.23
up
west #
 ../../guestbin/ping-once.sh --up -I 192.0.1.254 192.0.2.254
up
west #
 ipsec auto --down westnet-eastnet-nflog
"westnet-eastnet-nflog": ISAKMP SA is shared - only terminating IPsec SA
"westnet-eastnet-nflog" #2: deleting IPsec SA (QUICK_I2) and sending notification using ISAKMP SA #1
"westnet-eastnet-nflog" #2: ESP traffic information: in=168B out=168B
west #
 nft list ruleset
table inet ipsec-log {
	chain input {
		type filter hook input priority filter; policy accept;
		ipsec in reqid REQID ip saddr 192.1.2.23 ip daddr 192.1.2.45 counter packets 2 bytes 168 log group 50
	}
	chain output {
		type filter hook output priority filter; policy accept;
		ipsec out reqid REQID ip saddr 192.1.2.45 ip daddr 192.1.2.23 counter packets 2 bytes 168 log group 50
	}
}
west #
 ipsec auto --down west-east-nflog
"west-east-nflog": terminating SAs using this connection
"west-east-nflog" #3: deleting IPsec SA (QUICK_I2) and sending notification using ISAKMP SA "westnet-eastnet-nflog" #1
"west-east-nflog" #3: ESP traffic information: in=168B out=168B
west #
 nft list ruleset
table inet ipsec-log {
	chain input {
		type filter hook input priority filter; policy accept;
		ipsec in reqid REQID ip saddr 192.1.2.23 ip daddr 192.1.2.45 counter packets 2 bytes 168 log group 50
	}
	chain output {
		type filter hook output priority filter; policy accept;
		ipsec out reqid REQID ip saddr 192.1.2.45 ip daddr 192.1.2.23 counter packets 2 bytes 168 log group 50
	}
}
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.1.2.45 > 192.1.2.23: ICMP echo request, id XXXX, seq 1, length 64
IP 192.1.2.23 > 192.1.2.45: ICMP echo reply, id XXXX, seq 1, length 64
IP 192.1.2.45 > 192.1.2.23: ICMP echo request, id XXXX, seq 1, length 64
IP 192.1.2.23 > 192.1.2.45: 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
west #
 ipsec stop
Redirecting to: [initsystem]
west #
 # show no nflog left behind
west #
 iptables -L -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
west #
 
