I'm making a gui application which will control my laptop in order to make it act as a wifi hotspot. I may change distributions so I want to find a solution which will work generally for all distributions. I am currently doing this on Fedora 17.

Using NetworkManager's "Use as Hotspot" button works very well to create an ad-hoc hotspot: enter image description here

I want to recreate this functionality with terminal commands.

Below are two methods I tried to accomplish this but I havn't found a solution yet.

Method 1: iwconfig
Using research from accross the web, I tried the following command:

# ifconfig wlan0 netmask 255.555.255.0 broadcast up
# iwconfig wlan0 essid my-lappy mode ad-hoc key 0123456789
# iptables-restore < saved-hotspot-iptables
# echo 1 > /proc/sys/net/ipv4/ip_forward
# dhclient wlan0

where saved-hotspot-iptables is a file which I generated with iptables-save > saved-hotspot-iptables with the iptables set by the "Use as Hotspot" function.

Method 1 Problem
Devices can see the SSID but are unable to connect. Running ip a reveals the following about wlan0:

3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state DORMANT qlen 1000

Notice NO-CARRIER is present, and the state is DORMANT instead of UP.

Running ifconfig wlan0 shows the following:

wlan0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500

Notice that RUNNING is missing as one of the flags.

Method 2: nmcli
If NetworkManager's "Use as Hotspot" button is pressed at least once on the system, /etc/sysconfig/network-scripts/ifcfg-Hotspot is created and I can use the following command to start a working hotspot:

# ifconfig wlan0 up
# nmcli con up id Hotspot
# iwconfig wlan0 essid my-lappy key 0123456789

Method 2 Problem
If the user has never pressed "Use as Hotspot" on NetworkManager before, nmcli con up id Hotspot won't work. I've looked at nm-connection-editor --create but couldn't find much information. I've also looked into manually creating /etc/sysconfig/network-scripts/ifcfg-Hotspot but this method does not seem elegant or extendible to other distributions.

  • Please don't crosspost.
    – mgorven
    Commented Jun 23, 2012 at 0:20
  • 1
    Try wicd. It is similar to NetworkManager but has a text mode interface. I don't know if it has a hotspot feature. Commented Jun 23, 2012 at 0:40
  • Thanks for the tip Gilles, I'm going to try it out right away.
    – Daniel
    Commented Jun 27, 2012 at 13:34
  • @Gilles I tried wicd but it appears to have even less functionality then nmcli.
    – Daniel
    Commented Jul 6, 2012 at 15:07

3 Answers 3


There is a dedicated option in nmcli:

nmcli device wifi hotspot ifname wlan0 ssid toto password toto

More info from the Manual:

wifi hotspot [ifname ifname] [con-name name] [ssid SSID] [ band { a | bg } ] [channel channel] [password password] 

See my answer to the "Create wireless access point and share internet connection with nmcli"

I created a Hotspot with the GNOME Network-Manager. The problem was, that I can not configure the SSID and password in GUI. If you create the Hotspot with the Network-Manager GUI, it creates the file /etc/NetworkManager/system-connections/Hotspot. In that file it is possible to edit the SSID and the password.

sudo vim /etc/NetworkManager/system-connections/Hotspot

The content of the file looks like this:






I only changed the ssid and the psk properties to my needs. Then I restarted my computer because the command: sudo systemctl restart NetworkManager for network restart seems not to work correctly, because in the Network-Manager GUI I have no wireless network settings anymore and also the following command worked not before the restart. After restart you can use the nmcli command to start the access point.

nmcli con up Hotspot ifname YOUR_WIFI_INTERFACE

YOUR_WIFI_INTERFACE you can find out with the command iwconfig.


A DHCP server was needed to assign IP addresses to wifi connections. I used dnsmasq, a DNS and DHCP server.

The following are the commands to start an ad-hoc wifi hotspot:

# ifconfig wlan0 netmask 255.555.255.0 broadcast up
# iwconfig wlan0 essid my-lappy mode ad-hoc key 0123456789
# iptables-restore < saved-hotspot-iptables
# echo 1 > /proc/sys/net/ipv4/ip_forward
# dnsmasq -C /dev/null >/dev/null 2>&1 --bind-interfaces --listen-address= --dhcp-range=,,12h

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .