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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章