1. 程式人生 > >Linux系統設定WiFi熱點

Linux系統設定WiFi熱點

方法一:

第一步:安裝hostapd

      sudo apt-get install hostapd

      進入create_ap-master目錄直接make

第三步:建立熱點

      create_ap wlan0 eth0 hanbo -w2 12345678 &

            create_ap:建立熱點指令碼

            wlan0:WiFi網絡卡

            eth0:有線網絡卡

            hanbo:熱點名稱

            -w2: 加密方式WPA2

            12345678:密碼

            &:後臺執行

方法二:

第一步:安裝hostapd

      sudo apt-get install hostapd

第二步:安裝ap-hotspot

      sudo apt-get install ap-hotspot

      注意:如果安裝失敗,執行如下語句再安裝

            sudo add-apt-repository ppa:nilarimogard/webupd8

            sudo apt-get update

第三步:ap-hotspot使用說明

      start            start wireless hotspot               // 開啟wifi

      stop            stop wireless hotspot               // 停止wifi

      restart         restart wireless hotspot           // 重啟wifi

      configure    configure hotspot                     // 配置wifi

      debug         start with detailed messages   // dubug模式開啟wifi,會顯示一些詳細的資訊

第四步:AP配置

      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的密碼

第五步:啟動WiFi

      sudo ap-hotspot  start

          Starting Wireless Hotspot...
          Wireless Hotspot active 

注意:如果在除錯過程中 ap-hotspot start 出現 “Another process is already running” 

            ap-hotspot stop 無效問題

           可以sudo rm /temp/hotspot.pid 刪掉已啟動的程序

附:

      如果執行 "sudo ap-hotspot  start"後出現 "Starting Wireless Hotspot..."不動了,就是hostapd出現了問題

      a、tar -xvf hostap-1-hostap_1_1.tar.gz

      b、cd  hostap-1-hostap_1_1/hostapd

      c、cp defconfig .config

      d、安裝編譯環境

            apt-get install libnl-dev libpopt-dev openssl libssl-dev build-essential

      e、make

      f、make install (此安裝就是把hostapd和hostapd_cli放到了/usr/local/bin中)

      g、cp  hostapd  hostapd_cli  /usr/sbin (這是替換掉apt-get install hostapd安裝的程式,建議使用)