/testing/guestbin/swan-prep
road #
 ../../guestbin/wait-until-alive 192.0.2.254
destination 192.0.2.254 is alive
road #
 iptables -A INPUT -i eth0 -s 192.0.2.254 -p icmp -j DROP
road #
 iptables -I INPUT -m policy --dir in --pol ipsec -j ACCEPT
road #
 ../../guestbin/ping-once.sh --down 192.0.2.254
down
road #
 ipsec start
Redirecting to: [initsystem]
road #
 ../../guestbin/wait-until-pluto-started
road #
 ip route get to 192.1.2.23
192.1.2.23 via 192.1.3.254 dev eth0 src 192.1.3.209 uid 0
  cache
road #
 # this test need --verbose to see source address selection
road #
 ipsec auto --add --verbose road
opening file: /etc/ipsec.conf
loading named conns: road
resolving family=IPv4 src=<defaultroute> gateway=<defaultroute> peer 192.1.2.23
  seeking GATEWAY
    query GETROUTE+REQUEST+ROOT+MATCH
    add RTA_DST 192.1.2.23 (peer->addr)
    query returned 432 bytes
  processing response
    parsing route entry (RTA payloads)
      RTA_TABLE=254
      RTA_GATEWAY=192.1.3.254
      using src=<unset-address> prefsrc=<unset-address> gateway=192.1.3.254 dst=<unset-address> dev='eth0' priority=-1 pref=-1 table=254
    found gateway(host_nexthop): 192.1.3.254
  please-call-again: src=<defaultroute> gateway=192.1.3.254
resolving family=IPv4 src=<defaultroute> gateway=192.1.3.254 peer 192.1.2.23
  seeking PREFSRC
    query GETROUTE+REQUEST
    add RTA_DST 192.1.3.254 (host->nexthop)
    query returned 104 bytes
  processing response
    parsing route entry (RTA payloads)
      RTA_TABLE=254
      RTA_DST=192.1.3.254
      RTA_PREFSRC=192.1.3.209
      using src=<unset-address> prefsrc=192.1.3.209 gateway=<unset-address> dst=192.1.3.254 dev='eth0' priority=-1 pref=-1 table=254 +cacheinfo +uid
    found prefsrc(host_addr): 192.1.3.209
  success: src=192.1.3.209 gateway=192.1.3.254
resolving family=IPv4 src=192.1.2.23 gateway=<not-set> peer 192.1.3.209
  seeking NOTHING
"road": added IKEv2 connection
road #
 echo "initdone"
initdone
road #
 ipsec auto --up road
"road"[1] 192.1.2.23 #1: initiating IKEv2 connection to 192.1.2.23 using UDP
"road"[1] 192.1.2.23 #1: sent IKE_SA_INIT request to 192.1.2.23:UDP/500
"road"[1] 192.1.2.23 #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
"road"[1] 192.1.2.23 #1: sent IKE_AUTH request to 192.1.2.23:UDP/500
"road"[1] 192.1.2.23 #1: initiator established IKE SA; authenticated peer using authby=secret and ID_FQDN '@east'
"road"[1] 192.1.2.23 #2: received INTERNAL_IP4_ADDRESS 192.0.3.1
"road"[1] 192.1.2.23 #2: initiator established Child SA using #1; IPsec tunnel [192.0.3.1/32===0.0.0.0/0] {ESP/ESN=>0xESPESP <0xESPESP xfrm=AES_GCM_16_256-NONE DPD=passive}
road #
 ping6 -n -q -w 4 -c 2 192.0.2.254
ping6: 192.0.2.254: Address family for hostname not supported
road #
 ipsec trafficstatus
#2: "road"[1] 192.1.2.23, type=ESP, add_time=1234567890, inBytes=0, outBytes=0, maxBytes=2^63B, id='@east', lease=192.0.3.1/32
road #
 ../../guestbin/ip-addr-show.sh
eth0 inet 192.1.3.209/24
lo inet 192.0.3.1/32
road #
 ip -6 route
road #
 ip route get to 192.1.2.23
192.1.2.23 via 192.1.3.254 dev eth0 src 192.0.3.1 uid 0
  cache
road #
 #
road #
 # addconn need a non existing --ctlsocket
road #
 # otherwise this add bring the connection down.
road #
 #
road #
 # see the source address selection when the tunnel is established
road #
 ipsec addconn --verbose --ctlsocket /run/pluto/foo road
opening file: /etc/ipsec.conf
loading named conns: road
resolving family=IPv4 src=<defaultroute> gateway=<defaultroute> peer 192.1.2.23
  seeking GATEWAY
    query GETROUTE+REQUEST+ROOT+MATCH
    add RTA_DST 192.1.2.23 (peer->addr)
    query returned 628 bytes
  processing response
    parsing route entry (RTA payloads)
      RTA_TABLE=254
      RTA_DST=0.0.0.0
      RTA_PREFSRC=192.0.3.1
      RTA_GATEWAY=192.1.3.254
      using src=<unset-address> prefsrc=192.0.3.1 gateway=192.1.3.254 dst=0.0.0.0 dev='eth0' priority=-1 pref=-1 table=254
    parsing route entry (RTA payloads)
      RTA_TABLE=254
      RTA_GATEWAY=192.1.3.254
      using src=<unset-address> prefsrc=<unset-address> gateway=192.1.3.254 dst=<unset-address> dev='eth0' priority=-1 pref=-1 table=254
    found gateway(host_nexthop): 192.1.3.254
  please-call-again: src=<defaultroute> gateway=192.1.3.254
resolving family=IPv4 src=<defaultroute> gateway=192.1.3.254 peer 192.1.2.23
  seeking PREFSRC
    query GETROUTE+REQUEST
    add RTA_DST 192.1.3.254 (host->nexthop)
    query returned 104 bytes
  processing response
    parsing route entry (RTA payloads)
      RTA_TABLE=254
      RTA_DST=192.1.3.254
      RTA_PREFSRC=192.1.3.209
      using src=<unset-address> prefsrc=192.1.3.209 gateway=<unset-address> dst=192.1.3.254 dev='eth0' priority=-1 pref=-1 table=254 +cacheinfo +uid
    found prefsrc(host_addr): 192.1.3.209
  success: src=192.1.3.209 gateway=192.1.3.254
resolving family=IPv4 src=192.1.2.23 gateway=<not-set> peer 192.1.3.209
  seeking NOTHING
ERROR: ipsec addconn: Pluto is not running (no "/run/pluto/foo"): No such file or directory (errno 2)
road #
 echo done
done
road #
 if [ -f /var/run/pluto/pluto.pid ]; then ../../guestbin/ipsec-kernel-state.sh ; fi
src 192.1.3.209 dst 192.1.2.23
	proto esp spi 0xSPISPI reqid REQID mode tunnel
	replay-window 0 flag af-unspec esn
	aead rfc4106(gcm(aes)) 0xENCAUTHKEY 128
	anti-replay esn context:
	 seq-hi 0x0, seq 0xXX, oseq-hi 0x0, oseq 0xXX
	 replay_window 128, bitmap-length 4
	 00000000 00000000 00000000 XXXXXXXX 
src 192.1.2.23 dst 192.1.3.209
	proto esp spi 0xSPISPI reqid REQID mode tunnel
	replay-window 0 flag af-unspec esn
	aead rfc4106(gcm(aes)) 0xENCAUTHKEY 128
	anti-replay esn context:
	 seq-hi 0x0, seq 0xXX, oseq-hi 0x0, oseq 0xXX
	 replay_window 128, bitmap-length 4
	 00000000 00000000 00000000 XXXXXXXX 
road #
 if [ -f /var/run/pluto/pluto.pid ]; then ../../guestbin/ipsec-kernel-policy.sh ; fi
src 0.0.0.0/0 dst 192.0.3.1/32
	dir fwd priority PRIORITY ptype main
	tmpl src 192.1.2.23 dst 192.1.3.209
		proto esp reqid REQID mode tunnel
src 0.0.0.0/0 dst 192.0.3.1/32
	dir in priority PRIORITY ptype main
	tmpl src 192.1.2.23 dst 192.1.3.209
		proto esp reqid REQID mode tunnel
src 192.0.3.1/32 dst 0.0.0.0/0
	dir out priority PRIORITY ptype main
	tmpl src 192.1.3.209 dst 192.1.2.23
		proto esp reqid REQID mode tunnel
road #
 if [ -f /var/run/charon.pid -o -f /var/run/strongswan/charon.pid ]; then strongswan status ; fi
road #
 
