I have an internet connection through a cable modem. The IP address on the cable modem is not static and is perhaps obtained through a DHCP mode.

I wish to share this internet connection through the Wifi port available on my computer. Interestingly, the ad-hoc network setting does not work for my case on Ubuntu.

Therefore, I have set up my /etc/network/interfaces as follows:

auto lo
iface lo inet loopback

auto wlan0
iface wlan0 inet static

I am not clear with the process of routing, as I do not know the DHCP address until it is assigned i.e. only after I connect I will know the IP address of the system, and that IP address would be the one which the DHCP clients of my computer would use to route their internet connectivity.

Any clues on this?

2 Answers 2


Try ap-hotspot, which is a convenient wrapper around hostapd.


I assume you are connecting to internet through your eth0 and wish to share the connection to other computers via your wireless card (wlan0).

The reason what you have tried is failing is because your ubuntu only shares the connection as is, and your cable modem provider likely provides only one external IP address, which is given to your ubuntu computer. The other computers connecting to your newly created WiFi network are not getting IP addresses, and thus are not able to get connected.

Thus you have to install & enable a DHCP server on your ubuntu machine.

sudo apt-get install dnsmasq

and then configure it sudo nano /etc/dnsmasq.conf by adding the following lines in the "interface" section:


After this, your clients should get a IP address when connecting to the newly created WiFi network, and then the connection should be forwarded to the internet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.