I’m usind the Network Manager to configure a dialup IPSec VPN with a VIPs address (Require an inner IP address).
I’ve configured a NAT rule to map all traffic to the VIP address.
VPN is up. Ping is working but not all TCP packets are encryted and send through the tunnel.
I’m using Qubes 4.2 and debian based templates.
Flow: App-VM → Proxy-VM → sys-net
IP Legend:
192.168.1.198: IPSec Endpoint
192.168.1.196: VIPs / NAT / Client IP
192.168.2.141: Webserver
NAT configuration:
sudo nft add table nat
sudo nft -- add chain nat prerouting { type nat hook prerouting priority -100 \; }
sudo nft add chain nat postrouting { type nat hook postrouting priority 100 \; }
sudo nft add rule nat postrouting ip daddr 192.168.2.0/24 oif eth0 snat to 192.168.1.196
Interface Config:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group 1 qlen 1000
link/ether 00:16:3e:5e:6c:00 brd ff:ff:ff:ff:ff:ff
inet 10.137.0.6/32 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet 192.168.1.196/32 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::216:3eff:fe5e:6c00/64 scope link
valid_lft forever preferred_lft forever
4: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 500
link/none
inet 192.168.1.196/32 scope global noprefixroute tun0
valid_lft forever preferred_lft forever
inet6 fe80::f73c:21b:82a9:ba93/64 scope link stable-privacy
valid_lft forever preferred_lft forever
ip route list table 220
default via 10.137.0.20 dev eth0 proto static src 192.168.1.196
throw 10.137.0.20 proto static
throw 10.137.0.29 proto static
tcpdump on Net VM:
PING from APP_VM (all packets send trough the tunnel):
09:45:52.748579 IP 10.137.0.6.39355 > 192.168.1.198.ipsec-nat-t: UDP-encap: ESP(spi=0x8f7ee38c,seq=0x1c), length 136
09:45:52.891523 IP 192.168.1.198.ipsec-nat-t > 10.137.0.6.39355: UDP-encap: ESP(spi=0xcfc5c12b,seq=0x1e), length 136
09:45:53.750551 IP 10.137.0.6.39355 > 192.168.1.198.ipsec-nat-t: UDP-encap: ESP(spi=0x8f7ee38c,seq=0x1d), length 136
09:45:53.834457 IP 192.168.1.198.ipsec-nat-t > 10.137.0.6.39355: UDP-encap: ESP(spi=0xcfc5c12b,seq=0x1f), length 136
CURL from APP_VM (first 3 packets send through the Tunnel, other are send unecrypted but with the translated source address):
09:46:07.043438 IP 10.137.0.6.39355 > 192.168.1.198.ipsec-nat-t: UDP-encap: ESP(spi=0x8f7ee38c,seq=0x1e), length 104
09:46:07.234542 IP 192.168.1.198.ipsec-nat-t > 10.137.0.6.39355: UDP-encap: ESP(spi=0xcfc5c12b,seq=0x20), length 104
09:46:07.236173 IP 10.137.0.6.39355 > 192.168.1.198.ipsec-nat-t: UDP-encap: ESP(spi=0x8f7ee38c,seq=0x1f), length 88
09:46:07.241299 IP 192.168.1.196.42338 > 192.168.2.141.https: Flags [P.], seq 4215595036:4215595553, ack 2555776271, win 1004, length 517
09:46:07.856626 IP 192.168.1.196.42338 > 192.168.2.141.https: Flags [P.], seq 0:517, ack 1, win 1004, length 517
09:46:08.496473 IP 192.168.1.196.42338 > 192.168.2.141.https: Flags [P.], seq 0:517, ack 1, win 1004, length 517
09:46:09.712853 IP 192.168.1.196.42338 > 192.168.2.141.https: Flags [P.], seq 0:517, ack 1, win 1004, length 517
09:46:12.080704 IP 192.168.1.196.42338 > 192.168.2.141.https: Flags [P.], seq 0:517, ack 1, win 1004, length 517
after CTRL+C in APP_VM (all packets send trough the tunnel):
09:46:14.557523 IP 10.137.0.6.39355 > 192.168.1.198.ipsec-nat-t: UDP-encap: ESP(spi=0x8f7ee38c,seq=0x20), length 88
09:46:14.619088 IP 192.168.1.198.ipsec-nat-t > 10.137.0.6.39355: UDP-encap: ESP(spi=0xcfc5c12b,seq=0x21), length 104
09:46:14.620296 IP 10.137.0.6.39355 > 192.168.1.198.ipsec-nat-t: UDP-encap: ESP(spi=0x8f7ee38c,seq=0x21), length 600
09:46:14.644498 IP 192.168.1.198.ipsec-nat-t > 10.137.0.6.39355: UDP-encap: ESP(spi=0xcfc5c12b,seq=0x22), length 88
09:46:14.657890 IP 192.168.1.198.ipsec-nat-t > 10.137.0.6.39355: UDP-encap: ESP(spi=0xcfc5c12b,seq=0x23), length 1464
09:46:14.657935 IP 192.168.1.198.ipsec-nat-t > 10.137.0.6.39355: UDP-encap: ESP(spi=0xcfc5c12b,seq=0x24), length 136
09:46:14.657955 IP 192.168.1.198.ipsec-nat-t > 10.137.0.6.39355: UDP-encap: ESP(spi=0xcfc5c12b,seq=0x25), length 88
09:46:14.658942 IP 10.137.0.6.39355 > 192.168.1.198.ipsec-nat-t: UDP-encap: ESP(spi=0x8f7ee38c,seq=0x22), length 88
09:46:14.658992 IP 10.137.0.6.39355 > 192.168.1.198.ipsec-nat-t: UDP-encap: ESP(spi=0x8f7ee38c,seq=0x23), length 88
tcpdump on Proxy VM:
PING from APP_VM:
09:45:52.927093 IP 10.137.0.29 > 192.168.2.141: ICMP echo request, id 20432, seq 1, length 64
09:45:53.070916 IP 192.168.2.141 > 10.137.0.29: ICMP echo reply, id 20432, seq 1, length 64
09:45:53.928927 IP 10.137.0.29 > 192.168.2.141: ICMP echo request, id 20432, seq 2, length 64
09:45:54.013566 IP 192.168.2.141 > 10.137.0.29: ICMP echo reply, id 20432, seq 2, length 64
CURL from APP_VM:
09:46:07.222138 IP 10.137.0.29.42338 > 192.168.2.141.443: Flags [S], seq 4215595035, win 64240, options [mss 1460,nop,nop,sackOK,nop,wscale 6], length 0
09:46:07.414025 IP 192.168.2.141.443 > 10.137.0.29.42338: Flags [S.], seq 2555776270, ack 4215595036, win 64240, options [mss 1382,nop,nop,sackOK,nop,wscale 7], length 0
09:46:07.414687 IP 10.137.0.29.42338 > 192.168.2.141.443: Flags [.], ack 1, win 1004, length 0
09:46:07.419954 IP 10.137.0.29.42338 > 192.168.2.141.443: Flags [P.], seq 1:518, ack 1, win 1004, length 517
09:46:08.035276 IP 10.137.0.29.42338 > 192.168.2.141.443: Flags [P.], seq 1:518, ack 1, win 1004, length 517
09:46:08.675218 IP 10.137.0.29.42338 > 192.168.2.141.443: Flags [P.], seq 1:518, ack 1, win 1004, length 517
09:46:09.891407 IP 10.137.0.29.42338 > 192.168.2.141.443: Flags [P.], seq 1:518, ack 1, win 1004, length 517
after CTRL+C in APP_VM:
09:46:14.736009 IP 10.137.0.29.42338 > 192.168.2.141.443: Flags [F.], seq 518, ack 1, win 1004, length 0
09:46:14.798415 IP 192.168.2.141.443 > 10.137.0.29.42338: Flags [.], ack 1, win 502, options [nop,nop,sack 1 {518:519}], length 0
09:46:14.798815 IP 10.137.0.29.42338 > 192.168.2.141.443: Flags [P.], seq 1:518, ack 1, win 1004, length 517
09:46:14.823819 IP 192.168.2.141.443 > 10.137.0.29.42338: Flags [.], ack 519, win 501, length 0
09:46:14.837145 IP 192.168.2.141.443 > 10.137.0.29.42338: Flags [P.], seq 1:1432, ack 519, win 501, length 1431
09:46:14.837164 IP 192.168.2.141.443 > 10.137.0.29.42338: Flags [F.], seq 1432, ack 519, win 501, length 0
09:46:14.837599 IP 10.137.0.29.42338 > 192.168.2.141.443: Flags [R], seq 4215595554, win 0, length 0
09:46:14.837726 IP 10.137.0.29.42338 > 192.168.2.141.443: Flags [R], seq 4215595554, win 0, length 0