I am developing an application on macOS using NEPacketTunnelProvider.
Both our client and "VPN Server" are their own separate macOS application that uses NEPacketTunnelProvider.
On the server side, I have this as my configuration
The client is able to create and start the tunnel through System Preferences->Network successfully.
When the client receives packets through the virtual utun[x] interface, it forwards them to the the VPN Server.
When the VPN Server receives these packets (ex: SYN), it rewrites the source and destination IP addresses and injects them into its own utun[x] interface on the server's machine. In this case, it rewrites the source destination to 100.64.0.77 and the destination address to 192.168.1.95 (a web server).
Essentially what I want to happen is for the client to be able to communicate with a web server through the VPN server. What I expected was for the web server to receive this packet and respond appropriately with a SYN/ACK, which could then be used to read from the utun[x] interface and send back to the client. However, the web server does not receive any packets. Why is this the case and how can I get these packets to arrive at their destination?
Below I have attached my routing table on the server's side using netstat -nr:
Both our client and "VPN Server" are their own separate macOS application that uses NEPacketTunnelProvider.
On the server side, I have this as my configuration
Code Block let tunnelSettings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: "127.0.0.1") let ipv4Settings = NEIPv4Settings(addresses: ["100.64.0.77"], subnetMasks: ["255.255.255.0"]) let includedRoute = NEIPv4Route(destinationAddress: "192.168.1.0", subnetMask: "255.255.255.0") ipv4Settings.includedRoutes = [includedRoute] tunnelSettings.ipv4Settings = ipv4Settings //call setTunnelSettings to apply settings
The client is able to create and start the tunnel through System Preferences->Network successfully.
When the client receives packets through the virtual utun[x] interface, it forwards them to the the VPN Server.
When the VPN Server receives these packets (ex: SYN), it rewrites the source and destination IP addresses and injects them into its own utun[x] interface on the server's machine. In this case, it rewrites the source destination to 100.64.0.77 and the destination address to 192.168.1.95 (a web server).
Essentially what I want to happen is for the client to be able to communicate with a web server through the VPN server. What I expected was for the web server to receive this packet and respond appropriately with a SYN/ACK, which could then be used to read from the utun[x] interface and send back to the client. However, the web server does not receive any packets. Why is this the case and how can I get these packets to arrive at their destination?
Below I have attached my routing table on the server's side using netstat -nr:
Code Block Routing tables Internet: Destination Gateway Flags Netif Expire default 192.168.1.254 UGSc en0 default link#10 UCSI utun2 100.64.0.77 100.64.0.77 UH utun2 127 127.0.0.1 UCS lo0 127.0.0.1 127.0.0.1 UH lo0 169.254 link#7 UCS en0 ! 192.168.1 link#7 UCS en0 ! 192.168.1 link#10 UCSI utun2 192.168.1.92/32 link#7 UCS en0 ! 192.168.1.99 8c:a9:82:2e:d6:2e UHLWI en0 986 192.168.1.254/32 link#7 UCS en0 ! 192.168.1.254 70:f1:96:86:e6:a0 UHLWIir en0 1196 224.0.0/4 link#7 UmCS en0 ! 224.0.0/4 link#10 UmCSI utun2 224.0.0.251 1:0:5e:0:0:fb UHmLWI en0 255.255.255.255/32 link#7 UCS en0 ! 255.255.255.255/32 link#10 UCSI utun2