Thursday, October 30, 2014

Inernet Sharing 3G Usb Dongle over ethernet / wifi.



Recently I bought 3G Wireless stick.  I wanted to shared its internet connection to all my gazettes.

As usual Ubuntu was my friend.





Apparently,  it looked as a impossible task.

After a small research, I was successful.

My setup is as follows.

Ubuntu Version used : 14.04 LTS

3G dongle -  connected using wireless broadband connection.  ( ppp0 Interface )


           Ethernet port connected to wireless router.  ( eth0 interface )

           Ethernet card setup 
           ip : 192.168.1.25  

           netmask : 255.255.255.0
           gateway : 0.0.0.0  ( Important )
           dns : 8.8.8.8

          Wireless Router Setup
          Network : 192.168.1.1
          DHCP : Off    (optional )

Step 1:   Allow internet sharing  On Ubuntu.
From terminal window gave following command to enable packet       forwarding for IPv4
   
          sudo nano  /etc/sysctl.conf 

        &  uncomment following line & save the file.

          net.ipv4.ip_forward = 1  

To re-read the changes in systctl.conf file , following command is necessary.

          sudo  sysctl -p


Step  2:  Allow ppp0 interface traffic to interact with the eth0 -- 

sudo iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o ppp0 -j MASQUERADE



Step 3 :  On other devices, ensure that you give the manual ip  and gateway to its wireless connection.


Example :  On my Moto G

    ip : 192.168.1.30
   netmast : 255.255.255.0
   gateway :  192.168.1.25  ( very important --  this is a same ip of eth0 of Ubuntu system.

Switch on wifi connection on other devices.

In first go,  you will be able connect to Internet for sure.




No comments:

Post a Comment