ubuntu下设置一个wifi热点

我使用的是ap-hotspot,比较简单,命令行一共就三四步的样子。先来提一下配置的方法,然后讲我遇到的问题。
第一步:安装hoseapd和ap-hotspot。

sudo apt-get update
sudo apt-get install postapd
sudo apt-get install ap-hotspot

第二步:配置ap-hotspot

sudo ap-hotspot configure

Detecting configuration...
Detected eth0 as the network interface connected to the Internet. Press ENTER if this is correct or enter the desired interface below (e.g.- eth0, ppp0 etc.):
//什么也不输入,敲一下回车

Detected wlan0 as your WiFi interface. Press ENTER if this is correct or enter the desired interface (e.g.- wlan1):
//再敲一下回车
Enter the desired Access Point name or press ENTER to use the default one (myhotspot):
//输入wifi名称

Enter the desired WPA Passphrase below or press ENTER to use the default one (qwerty0987):
//输入wifi密码

第三步:热点启动

sudo ap-hotspot start

等到出现wireless hotspot active,这样一个wifi就启动了。
遇到的问题:
1、启动了以后进程一直阻塞着。
一直阻塞的话就是不成功,去/tmp/文件夹下查看hostapd的日志文件显示如下

Configuration file: /etc/ap-hotspot.conf                                                                                       
nl80211: Could not configure driver mode
nl80211 driver initialization failed.
hostapd_free_hapd_data: Interface wlan0 wasn't started

发现问题是nl80211后边这一串。解决办法是

//这两行的意思是先关闭wlan,然后关闭接口让ifconfig可以工作
sudo nmcli nm wifi off 
sudo rfkill unblock wlan
//用ifcongif升级wlan,然后允许一秒的延迟
sudo ifconfig wlan0 10.15.0.1/24 up
sleep 1
//重启设备
sudo service isc-dhcp-server restart
sudo service hostapd restart

问题解决。
这几个命令要在普通用户下运行,sudo权限个root用户下运行并不一样。
2、启动了以后终端提示Another process is already running
这是因为已经启动过一遍了,再启动一遍就会提示这个错误。解决办法是去临时文件夹下删除hotspot.pid文件。

sudo rm /tmp/hptspot.pid
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章