# Please install StrongSwan version >= 5.7.0 # Assuming your physical network device is eth0 sed -i 's/# install_routes = yes/install_routes = no/' /etc/strongswan.d/charon.conf sed -i 's/# install_virtual_ip = yes/install_virtual_ip = no/' /etc/strongswan.d/charon.conf cat < /etc/swanctl/conf.d/.conf conn-defaults { version = 2 proposals = aes128gcm16-prfsha512-ecp384 local_addrs = dpd_delay = 10s fragmentation = yes mobike = no rekey_time = 28800s unique = keep } child-defaults { dpd_action = clear start_action = none esp_proposals = aes128gcm16-ecp384 mode = transport start_action = none } connections { test : conn-defaults { remote_addrs = local { auth = psk id = @@ } remote { auth = psk id = @@ } children { tunnel : child-defaults { local_ts = remote_ts = mode = tunnel mark_in = 0x42424242/0xffffffff mark_out = 0x42424242/0xffffffff } transport : child-defaults { local_ts = dynamic[gre] remote_ts = dynamic[gre] mode = transport } } } } secrets { ike { secret = id-1 = @@ id-2 = @@ } } EOF # Omit this interface on one end ip tun add ipsec0 local remote mode vti key 0x42424242 dev eth0 ip addr add /31 dev ipsec0 sysctl -w net.ipv4.conf.ipsec0.disable_policy=1 ip link set ipsec0 mtu 1446 ip link set ipsec0 up ip tun add goips0 local remote mode gre dev eth0 ip addr add /31 dev goips0 ip link set goips0 mtu 1400 ip link set goips0 up swanctl -q swanctl -i -i test -c transport # Then do whatever you need on tunnel