【问题标题】:How to disable internet on all tethering data如何在所有网络共享数据上禁用互联网
【发布时间】:2016-08-22 15:05:53
【问题描述】:

我在托管网页的 android 设备上有一个应用程序。如果我通过它的 android 热点连接到运行它的设备,我可以使用默认 IP 查看页面。

此页面是从互联网提供的数据。所以安卓设备需要能够访问互联网。但是,我不希望连接到设备热点的用户能够访问互联网。我想知道切断android热点与其传出数据连接之间的数据桥的最佳方法是什么。 (我目前正在使用以太网。)

我更喜欢一个可以编辑固件本身的源文件的解决方案,因为这应该是不可逆转的。我可以完全控制源代码和 root。

提前致谢。

【问题讨论】:

  • 我应该提到我卡在运行 4.2.2。

标签: java android ethernet tethering android-firmware


【解决方案1】:

所以我突然得到了建议,让我看看安装在 android 4.2.2 中的 iptables。但是,此解决方案仅在您具有 root 权限时才有效。

谢天谢地,它显示了这一点:

Chain natctrl_FORWARD (1 references)
pkts bytes target     prot opt in     out     source               destination
0     0 natctrl_tether_counters  all  --  eth0   wlan0   0.0.0.0/0            0.0.0.0/0           [goto]  state RELATED,ESTABLISHED
0     0 DROP       all  --  wlan0  eth0    0.0.0.0/0            0.0.0.0/0            state INVALID
0     0 natctrl_tether_counters  all  --  wlan0  eth0    0.0.0.0/0            0.0.0.0/0           [goto]
0     0 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0

这个链是将数据从以太网传递到 wifi。因此,如果我在命令行中运行以下命令:

iptables -I natctrl_FORWARD 1 -j DROP

它只是将 DROP 放在顶部并丢弃所有流量。

所以在应用程序中,您可以使用以下命令运行命令行脚本:

Runtime.getRuntime().exec(new String[]{"su", "-c", "iptables -I natctrl_FORWARD 1 -j DROP"});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多