Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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: http://i.stack.imgur.com/7clAP.png

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 10.42.0.1 netmask 255.555.255.0 broadcast 10.42.0.255 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.

share|improve this question

closed as off topic by Shane Madden, mgorven, Chris S Jun 23 '12 at 21:45

Questions on Server Fault are expected to relate to professional server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.