C
C
Cctnata2016-11-17 00:09:08
Android
Cctnata, 2016-11-17 00:09:08

If the Internet is lost, the iptables rules are reset. Android 5. How to be?

The device on android 5
There are rules that I load on reboot.
Essence. I limit the connection only to a certain openvpn server and after connecting to which I make a wifi hotspot that distributes this connection to the device.
But when the connection is lost, the rules are reset.
The script itself is
iptables -F
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A INPUT -j ACCEPT -p udp -s xx.xx.xx.xx --sport 1194
iptables -A OUTPUT -j ACCEPT -p udp -d xx.xx.xx.xx --dport 1194
iptables -t filter -F FORWARD
iptables -t nat -F POSTROUTING
iptables -t filter -I FORWARD -j ACCEPT
iptables -t nat -I POSTROUTING -j MASQUERADE
ip rule add from 192.168.43.0/24 lookup 60
ip route add default dev tun0 scope link table 60
ip route add 192.168.43.0/24 dev ap0 scope link table 60
ip route add broadcast 255.255.255.255 dev ap0 scope link table 60

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question