sábado, 21 de junio de 2014

Here are some notes I use to setup my Ubuntu box a gateway to share my phone's data plan:

# Source: http://www.yourownlinux.com/2013/07/how-to-configure-ubuntu-as-router.html

1. Enable IP forwarding
    Enable the following in /etc/sysctl.conf
        net.ipv4.ip_forward=1

2. iptables:
    # To Wifi
    iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
    iptables -A FORWARD -i wlan0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
    iptables -A FORWARD -i eth1 -o wlan0 -j ACCEPT

    # To USB connection
    iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
    iptables -A FORWARD -i eth1 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
    iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT

3. Possibly persist iptables:
    iptables-save > /etc/iptables.rules