Blog / How-to Guides / How to share wired internet through wifi in Ubuntu (non Adhoc)

How to share wired internet through wifi in Ubuntu (non Adhoc)

An android mobile will be of greater use only when it has internet. Though the mobile network provides the internet facility, its too costly to use. If one has the wired modem and an ubuntu OS, then this post will be very useful especially if you are a naive user. This tutorial will definitely give you a step by step process for making your laptop a wifi in Ubuntu and to connect it with your android mobile. First let me tell you the need for this tutorial.

  1. Unrooted Android mobile doesn’t detect Adhoc network.
  2. There may be many tutorials in the net when you Google for wifi hotspots. It seems to be easy.But that is not complete.
  3. Finally this is a complete tutorial for newbies as i’m also a newbie

So first step is to create an adhoc network.This can be creating a wireless network.

Tutorial: Share wired internet through wifi in Ubuntu

Creating a wireless network (WiFi) in Ubuntu:

  1. Right click on the network icon on the top right corner.
  2. Select the option, Configure VPN and then select Edit Connections.In that click Wireless.
  3. Click Add option. Name the SSID and then give a password  by selecting the wireless security tab.
  4. Thus wireless network is created.

Packages to be downloaded for wifi hotspot:

  1. Hostapd
  2. DHCP

I would like to say the need to download these packages. Hostapd, converts  a wifi adapter into an access point.There is no native application to perform this.When a client connects with the access point, it needs IP address to make it available on the internet. This job of assigning IP address is done by DHCP server.If you think the word DHCP is weird please Google it.

Configuring Hostapd

Modify /etc/hostapd/hostapd.conf by pasting  the following. An editor can be opened by gedit command (if you are a newbie)

ssid=MyAP #the SSId you created before
wpa_passphrase=MyPasswordHere#Your password given for that wireless connection
wpa_pairwise=TKIP CCMP

Thats it. Hostapd is configured.

Configuring DHCP

Paste these lines in  /etc/dhcp3/dhcpd.conf file.

subnet netmask {
        option domain-name-servers,;
        option routers;

Let me explain you why these above lines are added. These lines interpret that there is a subnet with the network ID and its net mask is and the range of the subnet is from to . Thats it DHCP is configured. Up to this the connection between Access point and the device gets over. The internet forwarding is the next and the most important step.

Configuring the interface:

Modify /etc/default/dhcp3-server by adding wlan0


Paste the below lines in /etc/network/interfaces file

iface wlan0 inet static address netmask

The above lines add as the static address assigned to wlan0 interface.

Allow ip masquerading

The line allows IP forwarding

echo “1″ > /proc/sys/net/ipv4/ip_forward

This is the IPTables command used to masquerade the network.From this, the packets coming to wlan0 are redirected to eth0 interface which is connected to internet. iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Starting hostapd

hostapd -dd /etc/hostapd/hostapd.conf

Thus the device is connected to the internet. Enjoy unlimited internet.


  1. Diabolic Preacher says:

    Thank you for the easy to follow guide. I have been able to get my android device on the wifi network created on my Linux Mint laptop. I’m however not able to get access to the internet. Used static ip since I was not sure whether dhcp service exists or is running on the laptop.

    What do i need to do in order for the android mobile to be able to reach the internet.

    p.s. I am using Reliance Broadband, which provides a modem thru which my laptop gets a reliance ip and connects to the internet directly. Should there be some limitations due to this?

Leave a Reply