Skip to content
This repository has been archived by the owner on Jul 28, 2020. It is now read-only.

NEPacketTunnelProvider is not intercepting packets having local destination. #11

Open
MuhammadAliYousaf opened this issue Mar 16, 2018 · 11 comments

Comments

@MuhammadAliYousaf
Copy link

After enabling the NEPacketTunnelProvider, If I access a URL based on local IP address on Safari. PacketFlow.readPackets does not read that packet. And on Safari I got the response without any error.
Do I need to set any extra configuration to enable local traffic intercepting?
Please let me know of you need any other info.

@davlxd
Copy link
Owner

davlxd commented Mar 16, 2018 via email

@MuhammadAliYousaf
Copy link
Author

I hosted an image on tomcat installed on my machine. When I access that image on my device I did not get any breakpoint event in self.packetFlow.readPackets handler. Whereas if I try to access any other resource I did get that.
Please let me know you if you need any other info.
Thanks.

@davlxd
Copy link
Owner

davlxd commented Mar 19, 2018 via email

@MuhammadAliYousaf
Copy link
Author

I have included local host IP like this, do I need to configure something else as well?
tunnelNetworkSettings.iPv4Settings?.includedRoutes = [NEIPv4Route.init(destinationAddress: "172.16.15.36", subnetMask: "255.0.0.0")]

@davlxd
Copy link
Owner

davlxd commented Mar 19, 2018 via email

@MuhammadAliYousaf
Copy link
Author

It not working with the above code.
But now I fixed it by adding local IP address in the IPV4 settings as well. Following is the code.

tunnelNetworkSettings.iPv4Settings = NEIPv4Settings(addresses: [conf["ip"] as! String, "172.16.15.36"], subnetMasks: [conf["subnet"] as! String])

Whereas 172.16.15.36 is the ip address of my machine.

@MuhammadAliYousaf
Copy link
Author

MuhammadAliYousaf commented Mar 26, 2018

I fixed it. Actually, we need to add local machine ip address in the ipv4 settings as well. Like in the following code where my machine ip is 172.16.15.36.
tunnelNetworkSettings.ipv4Settings = NEIPv4Settings(addresses: [conf["ip"] as! String, "172.16.15.36"], subnetMasks: [conf["subnet"] as! String])
And of course, we need to include that ip in the includedRoutes as well.

@davlxd
Copy link
Owner

davlxd commented Mar 26, 2018 via email

@tuannv19
Copy link

I fixed it. Actually, we need to add local machine ip address in the ipv4 settings as well. Like in the following code where my machine ip is 172.16.15.36.
tunnelNetworkSettings.ipv4Settings = NEIPv4Settings(addresses: [conf["ip"] as! String, "172.16.15.36"], subnetMasks: [conf["subnet"] as! String])
And of course, we need to include that ip in the includedRoutes as well.

@alisolutions 172.16.15.36 is ip of current device (not server)?

@MuhammadAliYousaf
Copy link
Author

I fixed it. Actually, we need to add local machine ip address in the ipv4 settings as well. Like in the following code where my machine ip is 172.16.15.36.
tunnelNetworkSettings.ipv4Settings = NEIPv4Settings(addresses: [conf["ip"] as! String, "172.16.15.36"], subnetMasks: [conf["subnet"] as! String])
And of course, we need to include that ip in the includedRoutes as well.

@alisolutions 172.16.15.36 is ip of current device (not server)?

@tuannv19 Yes, this is IP of current device.

@tuannv19
Copy link

@alisolutions thanks you.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants