首页 > 解决方案 > NEPacketTunnelProvider 为什么我从这个 IP 17.130.21.5:443 获取数据包

问题描述

为了创建 NEPacketTunnelNetworkSettings 设置,我使用了下面的代码。

在这段代码中,我只添加"8.8.8.8", "1.1.1.1"了 IPV4 包含的路由和"2001:4860:4860::8888"IPV6 包含的路由。excludeRoutes 是默认的。

但是我从17.130.21.5:443这个 IP 收到了一些数据包。

- (NEPacketTunnelNetworkSettings *)createTunnelSettings {
    NEPacketTunnelNetworkSettings *settings = [[NEPacketTunnelNetworkSettings alloc] initWithTunnelRemoteAddress:@"127.1.1.1"];
    NEIPv4Settings *ipv4 = [[NEIPv4Settings alloc]
                            initWithAddresses:@[@"172.16.209.2"]
                            subnetMasks:@[@"255.255.255.252"]];

    NEIPv6Settings *ipv6 = [[NEIPv6Settings alloc]
                            initWithAddresses:@[@"fd12:1:1:1::2"]
                            networkPrefixLengths:@[ @(64)]];


    NEDNSSettings * dns = [[NEDNSSettings alloc] initWithServers: [@"8.8.8.8", @"1.1.1.1",@"2001:4860:4860::8888"]];
    NSMutableArray* ipv4IncludedRoutes = [NSMutableArray new];


    [ipv4IncludedRoutes addObject:[[NEIPv4Route alloc] initWithDestinationAddress:@"8.8.8.8"
                                                                       subnetMask:@"255.255.255.255"]];
    [ipv4IncludedRoutes addObject:[[NEIPv4Route alloc] initWithDestinationAddress:@"1.1.1.1"
                                                                       subnetMask:@"255.255.255.255"]];

    NSMutableArray* ipv6IncludedRoutes = [NSMutableArray new];
    [ipv6IncludedRoutes addObject:[[NEIPv6Route alloc] initWithDestinationAddress:@"2001:4860:4860::8888"
                                                              networkPrefixLength: @(128)]];

    ipv4.includedRoutes = ipv4IncludedRoutes;
    ipv6.includedRoutes = ipv6IncludedRoutes;

    ipv4.excludedRoutes = @[[NEIPv4Route defaultRoute]];
    ipv6.excludedRoutes = @[[NEIPv6Route defaultRoute]];

    dns.matchDomains = @[ @"" ];
    settings.DNSSettings = dns;

    if(ipv4Available) {
        settings.IPv4Settings = ipv4;
    }

    if(ipv6Available) {
        settings.IPv6Settings = ipv6;

    }
}
return settings;

}

标签: iosiphonevpntunnelnetworkextension

解决方案


推荐阅读