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 :
- Install necessary packages.
apt-get install iptables apt-get install dnsmasq apt-get install bridge-utils apt-get install iproute2
- Assign IP to eth0 interface
nano /etc/network/interface auto eth0 iface eth0 inet static address 192.168.1.100 netmask 255.255.255.0
- Set the kernel to router mode. Execute the following:
- Configure dnsmasq. Make the following changes to
domain-needed bogus-priv interface=eth0 dhcp-range=192.168.1.10,192.168.1.50,12h listen-address=127.0.0.1
Uncomment or Add the above lines as necessary. Change DHCP range according to your needs.
- Edit Network Manager configuration : /etc/NetworkManager/NetworkManager.conf. Comment the following.
- Restart Network Manager
- Restart dnsmasq
sh /etc/init.d/dnsmasq restart
- 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
- 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.
- Happy browsing. 🙂