博文

目前显示的是标签为“Ethernet”的博文

Android5.1双网卡NAT功能的iptables规则

    在Android5.1上面,我们参照了系统里的WiFi热点、USB Tether、Bluetooth Tether功能,发现有一组命令可实现双网卡的NAT网络地址转发功能:       echo 0 > /proc/sys/net/ipv4/ip_forward       /system/bin/iptables -t nat -A natctrl_nat_POSTROUTING -o eth0 -j MASQUERADE       /system/bin/iptables -A natctrl_FORWARD -i eth0 -o ap0 -m state --state ESTABLISHED,RELATED -g natctrl_tether_counters       /system/bin/iptables -A natctrl_FORWARD -i ap0 -o eth0 -m state --state INVALID -j DROP       /system/bin/iptables -A natctrl_FORWARD -i ap0 -o eth0 -g natctrl_tether_counters       /system/bin/iptables -A natctrl_tether_counters -i ap0 -o eth0 -j RETURN       /system/bin/iptables -A natctrl_tether_counters -i eth0 -o ap0 -j RETURN       /system/bin/iptables -D natctrl_FORWARD -j DROP       /system/bin/iptables -A natctrl_FORWARD -j D...