====== How to share 3G Connection over LAN on Ubuntu ======
I have a 3G connection on Ubuntu which I want to share to the rest network. What I need to to do is to make Ubuntu act as a NAT router to be able to share this connection.
Internet <-> 3G Stick <-> Ubuntu <-> eth0—Lan
From terminal:
sudo iptables -A FORWARD -o ppp0 -i eth0 -s 192.168.1.0/24 -m conntrack –ctstate NEW -j ACCEPT
#where ppp0 is 3G connection and eth0 the lan interface and 192.168.1.0 my LAN subnet.
sudo iptables -A FORWARD -m conntrack –ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -t nat -F POSTROUTING
sudo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
#Edit /etc/rc.local and add the following lines before the “exit 0″ line:
sudo iptables-save | sudo tee /etc/iptables.sav
sudo sh -c “echo 1 > /proc/sys/net/ipv4/ip_forward”
The ip address of eth0 is 192.168.1.1 so on client side I give this address as default gateway.Note that on this scenario I use static ip addresses on all clients as I have not setup dhcp server on ubuntu.