How to share 3g/4g connection over LAN in Ubuntu

In this post I am going to show you how to share a 3g or 4g dongle over LAN interface using ubuntu. Before beginning let me tell you what made me write this post in brief. A friend of mine purchased a TP-Link 3g WiFi router but unfortunately, his dongle was not supported. He needed WiFi by any means. As he was a Ubuntu user, I tried to use that system to connect to the Router and voila WiFi worked seamlessly.

Here is the network diagram :

Sharing 3g over LAN

Sharing 3g over LAN



  1. Install necessary packages.
    apt-get install iptables
    apt-get install dnsmasq
    apt-get install bridge-utils
    apt-get install iproute2
  2. Assign IP to eth0 interface
    nano /etc/network/interface
    auto eth0
    iface eth0 inet static
  3. Set the kernel to router mode. Execute the following:
    sysctl net.ipv4.ip_forward=1
  4. Configure dnsmasq. Make the following changes to /etc/dnsmasq.conf


    Uncomment or Add the above lines as necessary. Change DHCP range according to your needs.

  5. Edit Network Manager configuration  : /etc/NetworkManager/NetworkManager.conf. Comment the following.
  6. Restart Network Manager
    restart network-manager
  7. Restart dnsmasq
    sh /etc/init.d/dnsmasq restart
  8. Set firewall to forward connections to and from the Internet for clients connected to your LAN. This is done by issuing:
    iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

    Here eth0 is the LAN Interface connected to Router or Switch

  9. From here steps are optional and depends on your requirements…
    If you are connected by a switch then plug in a cable from switch to eth0 and other PCs to switch. Clients will automatically get IP using DHCP.
    If you are connected by a router then plug in WAN port of router to eth0 port.
    Set up IP addressing as mentioned in the diagram.
  10. Happy browsing. 🙂

Video tutorial coming soon.  

Enjoyed this post? Share it!