[Networking] Applied Protocol:
A script for port fowarding

This is a script for port forwarding for gaming I do not know the ports needed for your game these are ports for rainbow six it does open most ports to be used so it should work.

You should experiment with this script to use only the least amount of ports if it does not work then delete the comments ( #) and try again. To use install AFWALL with root and when you want to play then put this script in to the custom script section

To find the name of your network tethered network connection first run this code

ifconfig -s | cut -d' ' -f1 | grep -v Iface

then do it again after the connection is made and comparing it will tell you your tethered network interface I know I should write a script for this.....

#!system/bin/sh
###################################
#
# File name gameonipt.sh
# Iptables Gaming script for Android
# Opens ports needed for Gaming on a
# tethered connection use minimaly
# By Applied Protocol
#
###################################
#
IPTABLES=system/bin/iptables
IP6TABLES=system/bin/ip6tables

## Interface Setup
# should change to your network interfaces
# Tethering Interface
INT_INT="rndis+"
# Put your local lan address from the tethered connection here
IP_INT=""
# Internet Interface
# can use wimax+ for wifi
EXT_INT="rmnet+"

## Ports to Open
# This should be adjusted to be kept to a minimum ports
# here are everything needed to make a connection
TCP_PORT="80 443 13000 13005 13200 14000 14001 14008"
UDP_PORT="3074 9103"
UDP_PORT_RANGE="10000:10099 50000:60000 49152:65535"

### INPUT Chain

# Start with New Rules
$IPTABLES -F
$IPTABLES -F -t nat
$IPTABLES -X
$IPTABLES -P INPUT DROP
$IPTABLES -P OUTPUT DROP
$IPTABLES -P FORWARD DROP
$IPTABLES -t nat -F POSTROUTING
$IPTABLES -F -t mangle
$IPTABLES -t mangle -X
$IP6TABLES -F
$IP6TABLES -F -t nat
$IP6TABLES -X
$IP6TABLES -P INPUT DROP
$IP6TABLES -P OUTPUT DROP
$IP6TABLES -P FORWARD DROP
$IP6TABLES -t nat -F POSTROUTING
$IP6TABLES -F -t mangle
$IP6TABLES -t mangle -X

## Connection Tracking
$IPTABLES -A INPUT -m state --state INVALID -j DROP
$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IP6TABLES -A INPUT -m state --state INVALID -j DROP
$IP6TABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

### FOWARD Chain

## Connection Tracking
$IPTABLES -A FORWARD -m state --state INVALID -j DROP
$IP6TABLES -A FORWARD -m state --state INVALID -j DROP

## Allow Selected Ports
for ip in $TCP_PORT
do
$IPTABLES -A FORWARD -i $INT_INT -o $EXT_INT -s $IP_INT -p tcp --sport $TCP_PORT -m state --state NEW -j ACCEPT
$IPTABLES -A FORWARD -p tcp --sport $TCP_PORT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IP6TABLES -A FORWARD -i $INT_INT -o $EXT_INT -s $IP_INT -p tcp --sport $TCP_PORT -m state --state NEW -j ACCEPT
$IP6TABLES -A FORWARD -p tcp --sport $TCP_PORT -m state --state ESTABLISHED,RELATED -j ACCEPT
done

for ip in $UDP_PORT
do
$IPTABLES -A FORWARD -i $INT_INT -o $EXT_INT -s $IP_INT -p udp --sport $UDP_PORT -m state --state NEW -j ACCEPT
#$IPTABLES -A FORWARD -p udp --sport $UDP_PORT -j ACCEPT
$IP6TABLES -A FORWARD -i $INT_INT -o $EXT_INT -s $IP_INT -p udp --sport $UDP_PORT -m state --state NEW -j ACCEPT
#$IP6TABLES -A FORWARD -p udp --sport $UDP_PORT -j ACCEPT
done

for ip in $UDP_PORT_RANGE
do
$IPTABLES -A FORWARD -i $INT_INT -o $EXT_INT -s $IP_INT -p udp -m multiport --sport $UDP_PORT_RANGE -m state --state NEW -j ACCEPT
#$IPTABLES -A FORWARD -p udp -m multiport --sport $UDP_PORT_RANGE -j ACCEPT
$IP6TABLES -A FORWARD -i $INT_INT -o $EXT_INT -s $IP_INT-p udp -m multiport --sport $UDP_PORT_RANGE -m state --state NEW -j ACCEPT
#$IP6TABLES -A FORWARD -p udp -m multiport --sport $UDP_PORT_RANGE -j ACCEPT
done

## NAT Table

$IPTABLES -t nat -A POSTROUTING -o $EXT_INT -j MASQUERADE

## Turn on IP fowarding
echo 1 > /proc/sys/net/ipv4/ip_forward

exit
### EOF ###

This goes without saying that this is a really open script and should be user (even after the ports needed are selected) only for select times afterward turn off your tethered connection. Any port that you do not need delete and if no ports of that type are needed comment out then bottom with that request.

GAME ON