Configuring NAT via iptables - chhwang/devel-note GitHub Wiki
On gateway machine:
sysctl net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -o <online_device> -j MASQUERADE
iptables -A FORWARD -i <online_device> -o <lan_device> -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i <lan_device> -o <online_device> -j ACCEPT
On client machine:
ip route del default
ip route add default via <ip_of_gateway_machine>