I run a backend on DO infrastructure, call it site Yvi, that connects to a third party site Prov via an IPsec tunnel, with this libreswan config:
conn prov-client
...
right=$YVI_IP
rightsourceip=10.31.3.1
rightsubnet=10.31.3.0/28
left=$PROV_IP
leftsubnet=10.70.0.36/28
Prov has a server running on 10.70.0.37
, and I'm able to interact with it from Yvi.
My problem is that I'm setting up a local dev environment (an Ubuntu box in another network), and each time I make a change I have to deploy to Yvi because only from there can I reach the API in Prov. I'd like to avoid this by connecting Local to Yvi and route that traffic to Prov to be able to reach the API in Prov from Local and ease development.
I connect Local to Yvi as a road warrior with the following conf:
conn remote-dev-client
...
left=$YVI_IP
leftsubnet=10.31.3.0/28
right=%any
rightaddresspool=10.31.4.1-10.31.4.254
Connection is established successfully and from Local I can reach 10.31.3.1
on Yvi. What I want is to reach 10.70.0.37
in Prov from Local. The route to the 10.70.0.36/28
network is not added automatically, so I tried setting some ip xfrm
and ip route
rules manually on Local:
# Outgoing
ip xfrm policy add dst 10.70.0.37 src 10.31.4.1 dir out tmpl src $LOCAL_IP dst $YVI_IP proto esp spi $SPI reqid $REQID mode tunnel priority 100000
# Incoming
ip xfrm policy add dst 10.31.4.1 src 10.70.0.37 dir fwd tmpl src $YVI_IP dst $LOCAL_IP proto esp reqid $REQID mode tunnel priority 100000
ip xfrm policy add dst 10.31.4.1 src 10.70.0.37 dir in tmpl src $YVI_IP dst $LOCAL_IP proto esp reqid $REQID mode tunnel priority 100000
ip route add table 220 src 10.31.4.1 10.70.0.37 via $LOCAL_IP dev $LOCAL_IF proto static
I now run ip xfrm monitor
on Yvi and then from Local ping 10.70.0.37
; I can see the packets arriving at Yvi (from the xfrm monitor in Yvi), but only the outgoing, not the response (as is seen if I ping 10.31.3.1, for example), suggesting that Yvi is receiving the traffic but not routing it to Prov? I really don't know how to interpret this.
I think I have to add routes in Yvi to route the traffic to the Prov API correctly, but adding similar rules to the ones above hasn't worked. I'd appreciate help in understanding what I'm missing, and what I'm doing wrong.
Suggestions for a different approach are also welcome, although the only way to connect to Prov, which I don't control, is through an IPsec tunnel from Yvi, which I do control.