Create A WiFi Hotspot On Linux

An in-depth tutorial on creating a hotspot in Linux

AIM: To create a WiFi hotspot on a Linux machine to share a wireless connection on a single wireless card

Moving from a Windows environment on to a Linux the first real challenge I faced was that I need to share the internet on my laptop. But unlike with windows where it was one button to rule them all I found that setting a WiFi hotspot on a Linux system was a bit more tedious affair.

For Starters, I looked at online solutions and found out the hard way that most of the implementations were either to share an Ethernet network using a wireless card or a set up using two wireless cards.


You got to know a bit about the terminal and basic network to get through this guide follow it to the dot and you should be fine. you can just skip over all the explanation and run the commands it should work. probably…


To get started to set up a hotspot on a single wireless card requires some basic knowledge about networks and the terminal. The plan is rather simple.

  1. Check to see if your wireless card supports access point creation.
  2. Setup a virtual interface on the card as an access point using iw command
  3. Setup hotspot using Hostapd
  4. Create a DHCP service to provide IP address and configurations for the clients
  5. Test everything works properly and that's it


  • iw: it is a new nl80211 based CLI configuration utility for wireless devices. It supports all new drivers that have been added to the kernel recently. The old tool iwconfig, which uses Wireless Extensions interface, is deprecated and it’s strongly recommended to switch to iw and nl80211.
  • hostapd: hostapd is a user-space daemon-process software to manage, host and implement wireless access points on the fly under the influence of nl80211 driver which still is under development phase and not yet fully supported by many adapters. installation sudo apt install hostapd
  • udhcpd: a very small DHCP program installation sudo apt install udhcpd


I am using a KDE Neon Linux based system running on a hp notebook laptop. along with all the tools mentioned above installed.

Configurations and running

step 1: check to see if the system supports access point supports for this run the command iw list

You should see an output as below

Scroll up to where it says supported interface modes and check to see if AP is listed. If so we are good to go…

step 2: Now we move on the most important step setting up a virtual wireless interface on top of our existing interface. this is also done using the iw command sudo iw phy phy0 interface add new1 type __ap

run the above command and then run ifconfig -a to list all devices. In the above, you may need to replacephy0 to your device's physical name to see all physical devices use iw phy command.

the output of iw phy command

now we need to set up the IP for our new interface. I am going to use as my network address and for my interface, I am going to use the IP To set the IP use the following command.

and voila.

So far we have created and configured a virtual interface, now to move on one of the most important steps is, to use hostapd to create the actual hotspot.

Step 3: Setting up the hostapd. We first need to configure the hostapd. I am going to create a hostapd.conf file in my home directory and then open it. I am going to use vi. a sample configuration is shown below.

don’t worry I changed my password 😚 😉

the final step is to run it using the command : sudo hostapd hostapd.conf

now if you were to scan for the WiFi you will see your hotspot. If you try to connect now with your password you can authorize on to the network but your device will fill fail to obtain any configurations either you can set it manually which is quite troublesome. But in most common networks we have a DHCP server and clients get their configurations from this server so let’s set up one for our local access point network.

Step 4: Configuring the DHCP server. I am going to the DHCP server configuration to the file /etc/udhcpd.conf file. a sample configuration is shown below. you should already have some sample configuration in the file just edit the file as described below

# setiing up the range of address for our network
start #default:
end #default:
#the Interface to run the dhcp server on
interface hotspot #default: eth0
# leave most of these as isopt dns
option subnet
opt router
option domain local
option lease 864000 # 10 days of seconds

One thing you have to note is the router address should be the address of your other interface.

to get the address of the other interface use ifconfig -a to list all connections and select the IP address of your specific connection. in my case, it is for interface wlo1

sample configuration
the output of ifconfig -a

Now that’s it the DHCP is configured you can run as sudo service udhcpd restart but for me, it seems to not work for some strange reason so I just ran it directly from the terminal using the following command sudo udhcpd -f

Now try connecting to your hotspot and you should be able to connect and receive the configurations too. and you should see something as shown below

the hostapd output on left and DHCP client output on the right.

So pretty cool right you just created a hotspot configured the DHCP and it pretty much is over. but if you try to access the internet from your client device now it does not have any actual internet. To solve this we need to do just one more step that is to configure an IP forward. Basically route all our requests on our local network over to our card connected to the internet.

run sudo su to move on to a superuser terminal

now run the following commands. NOTE: replace wlo1 with your interface name, that is the interface that is connected to the internet

echo "1" > /proc/sys/net/ipv4/ip_forwardiptables --table nat --append POSTROUTING --out-interface wlo1 -j MASQUERADEiptables --append FORWARD --in-interface hotspot -j ACCEPT

all done we now have the internet on the client device.


That’s it all done. if any of you find the time to automate this please let me know or if there is a better way to do the same.

you can find me at

GitHub: @anooppoommen


Just another cartoon