<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>
</p>
<div class="moz-text-flowed" style="font-family: -moz-fixed;
font-size: 14px;" lang="x-unicode">Hello,
<br>
<br>
Any pointers on this request are greatly appreciated...
<br>
<br>
I'm trying to configure a client-server architecture using
transport mode and
<br>
shared secret auth. By default, all communication will be
encrypted, but
<br>
there will be a small exception list based on port and protocol.
Anything on
<br>
the exception list is sent cleartext, the rest is encrypted.
<br>
<br>
So I tried a simple setup using the test
environment, based on
<br>
ikev2/host2host-transport, where I attempt to bypass tcp/5001
traffic, but
<br>
encrypt everything else:
<br>
<br>
moon:
<br>
> conn %default
<br>
> ikelifetime=60m
<br>
> keylife=20m
<br>
> rekeymargin=3m
<br>
> keyingtries=1
<br>
> mobike=no
<br>
> keyexchange=ikev2
<br>
>
<br>
> conn client-1
<br>
> left=192.168.0.1
<br>
> right=192.168.0.2
<br>
> leftfirewall=yes
<br>
> type=transport
<br>
> authby=secret
<br>
> auto=add
<br>
>
<br>
> conn client-1-bypass
<br>
> left=192.168.0.1
<br>
> right=192.168.0.2
<br>
> rightsubnet=192.168.0.2[tcp/5001]
<br>
> leftfirewall=yes
<br>
> type=passthrough
<br>
> authby=secret
<br>
> auto=add
<br>
<br>
sun:
<br>
<br>
> conn %default
<br>
> ikelifetime=60m
<br>
> keylife=20m
<br>
> rekeymargin=3m
<br>
> keyingtries=1
<br>
> mobike=no
<br>
> keyexchange=ikev2
<br>
>
<br>
> conn server
<br>
> left=192.168.0.2
<br>
> leftfirewall=yes
<br>
> right=%any
<br>
> type=transport
<br>
> authby=secret
<br>
> auto=add
<br>
>
<br>
> conn server-bypass
<br>
> left=192.168.0.2
<br>
> leftsubnet=192.168.0.2[tcp/5001]
<br>
> right=%any
<br>
> leftfirewall=yes
<br>
> type=passthrough
<br>
> authby=secret
<br>
> auto=add
<br>
<br>
In short, it doesn't work. All traffic, everything sent from
moon, INCLUDING
<br>
tcp/5001, as detected via nflog samples. Moon shows the
<br>
bypass connection in charon (sun is similar):
<br>
<br>
> >>> moon: ipsec statusall
<br>
>
<br>
> No leaks detected, 1 suppressed by whitelist
<br>
> Status of IKE charon daemon (strongSwan 5.4.0, Linux 4.2.0,
x86_64):
<br>
> uptime: 70 seconds, since Jul 11 16:50:38 2016
<br>
> malloc: sbrk 1613824, mmap 0, used 1533264, free 80560
<br>
> worker threads: 11 of 16 idle, 5/0/0/0 working, job queue:
0/0/0/0, scheduled: 3
<br>
> loaded plugins: charon aes des sha1 sha2 md5 pem pkcs1 gmp
random nonce x509 curl revocation hmac xcbc stroke kernel-netlink
socket-default updown
<br>
> Listening IP addresses:
<br>
> 192.168.0.1
<br>
> fec0::1
<br>
> 10.1.0.1
<br>
> fec1::1
<br>
> Connections:
<br>
> client-1: 192.168.0.1...192.168.0.2 IKEv2
<br>
> client-1: local: [192.168.0.1] uses pre-shared key
authentication
<br>
> client-1: remote: [192.168.0.2] uses pre-shared key
authentication
<br>
> client-1: child: dynamic === dynamic TRANSPORT
<br>
> client-1-bypass: 192.168.0.1...192.168.0.2 IKEv2
<br>
> client-1-bypass: local: [192.168.0.1] uses public key
authentication
<br>
> client-1-bypass: remote: [192.168.0.2] uses public key
authentication
<br>
> client-1-bypass: child: dynamic ===
192.168.0.2/32[tcp/5001] PASS
<br>
> Security Associations (1 up, 0 connecting):
<br>
> client-1[1]: ESTABLISHED 70 seconds ago,
192.168.0.1[192.168.0.1]...192.168.0.2[192.168.0.2]
<br>
> client-1[1]: IKEv2 SPIs: 84ed7d2dd12991e2_i*
b824367052186ce5_r, pre-shared key reauthentication in 52 minutes
<br>
> client-1[1]: IKE proposal:
AES_CBC_128/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/MODP_3072
<br>
> client-1{1}: INSTALLED, TRANSPORT, reqid 1, ESP SPIs:
cc2755c5_i c0ec6ec6_o
<br>
> client-1{1}: AES_CBC_128/HMAC_SHA2_256_128, 0 bytes_i, 0
bytes_o, rekeying in 13 minutes
<br>
> client-1{1}: 192.168.0.1/32 === 192.168.0.2/32
<br>
<br>
However, moon shows the policies for the bypass as
havingtemplates:
<br>
<br>
> moon:~# ip xfrm policy
<br>
> ip xfrm policy
<br>
> src 192.168.0.2/32 dst 192.168.0.1/32 proto tcp sport 5001
<br>
> dir fwd priority 2816 ptype main
<br>
> tmpl src 192.168.0.2 dst 192.168.0.1
<br>
> proto esp reqid 2 mode tunnel
<br>
> src 192.168.0.2/32 dst 192.168.0.1/32 proto tcp sport 5001
<br>
> dir in priority 2816 ptype main
<br>
> tmpl src 192.168.0.2 dst 192.168.0.1
<br>
> proto esp reqid 2 mode tunnel
<br>
> src 192.168.0.1/32 dst 192.168.0.2/32 proto tcp dport 5001
<br>
> dir out priority 2816 ptype main
<br>
> tmpl src 192.168.0.1 dst 192.168.0.2
<br>
> proto esp reqid 2 mode tunnel
<br>
> src 192.168.0.2/32 dst 192.168.0.1/32
<br>
> dir in priority 2819 ptype main
<br>
> tmpl src 0.0.0.0 dst 0.0.0.0
<br>
> proto esp reqid 1 mode transport
<br>
> src 192.168.0.1/32 dst 192.168.0.2/32
<br>
> dir out priority 2819 ptype main
<br>
> tmpl src 0.0.0.0 dst 0.0.0.0
<br>
> proto esp reqid 1 mode transport
<br>
> src 0.0.0.0/0 dst 0.0.0.0/0
<br>
> socket in priority 0 ptype main
<br>
> src 0.0.0.0/0 dst 0.0.0.0/0
<br>
> socket out priority 0 ptype main
<br>
> src 0.0.0.0/0 dst 0.0.0.0/0
<br>
> socket in priority 0 ptype main
<br>
> src 0.0.0.0/0 dst 0.0.0.0/0
<br>
> socket out priority 0 ptype main
<br>
<br>
which creates SAs for the "bypass", so no surprise that the
tcp/5001 traffic
<br>
is encrypted too:
<br>
<br>
> moon:~# ip xfrm state
<br>
> ip xfrm state
<br>
> src 192.168.0.1 dst 192.168.0.2
<br>
> proto esp spi 0xcb00e25f reqid 1 mode transport
<br>
> replay-window 32
<br>
> auth-trunc hmac(sha256)
0x839ea14d6fbfa28c198433b23bea2926271ed09b6afd6ec1e1c362ecf2558e05
128
<br>
> enc cbc(aes) 0x0fe599c09755bf3956266f09fda7e01d
<br>
> sel src 192.168.0.1/32 dst 192.168.0.2/32
<br>
> src 192.168.0.2 dst 192.168.0.1
<br>
> proto esp spi 0xcc7307e9 reqid 1 mode transport
<br>
> replay-window 32
<br>
> auth-trunc hmac(sha256)
0x86f6e022d784c2cf809c4f9700a025584abdfa11e18c04a20d0a95865e62809b
128
<br>
> enc cbc(aes) 0x27113998c69fdba3ab6baae003ff0501
<br>
> sel src 192.168.0.2/32 dst 192.168.0.1/32
<br>
> src 192.168.0.1 dst 192.168.0.2
<br>
> proto esp spi 0xc6318982 reqid 2 mode tunnel
<br>
> replay-window 32 flag af-unspec
<br>
> auth-trunc hmac(sha256)
0xc53e385238df420ba7ab3c8b5d337ed54e54a2e4faf7730b2efdaf941bdc3648
128
<br>
> enc cbc(aes) 0xeafb109579c86fe21fb25b1061295eec
<br>
> src 192.168.0.2 dst 192.168.0.1
<br>
> proto esp spi 0xc1629f74 reqid 2 mode tunnel
<br>
> replay-window 32 flag af-unspec
<br>
> auth-trunc hmac(sha256)
0x241897c993d33184817e0932f72396c6f3d15aa2f175426a0b7d33caefe5c3e7
128
<br>
> enc cbc(aes) 0x60b64dd6ff61e6112ef68f9a40637c9e
<br>
<br>
I thought that to force a "exception policy," one should
install a policy
<br>
<b class="moz-txt-star"><span class="moz-txt-tag">*</span>without<span
class="moz-txt-tag">*</span></b> an associated template.
The presence of template is normally a
<br>
signal to the kernel to create an SA bundle, and it's absence
is a way to
<br>
request cleartext transmission.
<br>
<br>
Finally, I tried to get the bypass to work by removing
client-1-bypass and
<br>
server-bypass config. Then added my own bypass policies:
<br>
<br>
moon:
<br>
ip xfrm policy add dst 192.168.0.2/32 proto tcp dport 5001 dir
out priority 100 ptype main action allow
<br>
ip xfrm policy add dst 192.168.0.2/32 proto tcp dport 5001 dir
fwd priority 100 ptype main action allow
<br>
ip xfrm policy add dst 192.168.0.1/32 proto tcp sport 5001 dir
in priority 100 ptype main action allow
<br>
<br>
sun:
<br>
ip xfrm policy add dst 192.168.0.1/32 proto tcp dport 5001 dir
out priority 100 ptype main action allow
<br>
ip xfrm policy add dst 192.168.0.1/32 proto tcp dport 5001 dir
fwd priority 100 ptype main action allow
<br>
ip xfrm policy add dst 192.168.0.2/32 proto tcp sport 5001 dir
in priority 100 ptype main action allow
<br>
<br>
But, in this case, all tcp/5001 traffic from moon is <b
class="moz-txt-star"><span class="moz-txt-tag">*</span>dropped<span
class="moz-txt-tag">*</span></b> by xfrm (as
<br>
verified by nflog output).
<br>
<br>
I'd be happy to get manual bypass to work and use strongSwan for
the default
<br>
encryption path. I'm perplexed as to why the above manual bypass
doesn't work.
<br>
<br>
Any ideas?
<br>
<br>
Thank you in advance.
<br>
<br>
Plevin
<br>
<br>
</div>
</body>
</html>