方法/步驟
榆林網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián),榆林網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為榆林成百上千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站制作要多少錢(qián),請(qǐng)找那個(gè)售后服務(wù)好的榆林做網(wǎng)站的公司定做!
安裝hostapd無(wú)線網(wǎng)認(rèn)證程序。
sudo apt-get install hostapd
安裝小型DNS/TFTP服務(wù)器。
sudo apt-get install dnsmasq
安裝iptables。默認(rèn)deepin linux下已經(jīng)安裝。
sudo apt-get install iptables
安裝git,需要克隆github上的create_ap。sudo apt-get install git
建立一個(gè)文件夾,并初始化git倉(cāng)庫(kù),以便克隆github上的工具。
克隆github上的ap創(chuàng)建工具create_ap。
克隆完成,執(zhí)行如下命令安裝create_ap。
sudo make install
接下來(lái)查看自己電腦上網(wǎng)絡(luò)名稱(chēng)。
最后通過(guò)create_ap來(lái)創(chuàng)建wifi熱點(diǎn),命令格式:
create_ap 無(wú)線網(wǎng)卡 有線網(wǎng)卡 熱點(diǎn)名稱(chēng) 密碼
比如我的電腦創(chuàng)建一個(gè)密碼為110120114的叫mywifi的熱點(diǎn)。
sudo create_ap wlan0 enxb827eb03ac05 mywifi 110120114
開(kāi)啟后,其它無(wú)線設(shè)備就可以在無(wú)線網(wǎng)掃描中找到mywifi的網(wǎng)絡(luò),輸入密碼即可上網(wǎng)了。
第一步:安裝應(yīng)用;
apt-get install hostapd dnsmasq
第二步:配置文件;
修改/etc/hostapd/hostapd.conf
1
2
3
4
5
6
7
8
9
10
interface=wlan0
driver=nl80211
ssid=hotspot # Your WAP name, change it to something more unique
hw_mode=g
channel=6 # You may want to change this if the channel is too crowded
wpa=1
wpa_passphrase=hotspot_password # Password for clients
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
wpa_ptk_rekey=600
修改/etc/dnsmasq.conf
1
2
3
4
5
6
7
8
9
# disables dnsmasq reading any other files like /etc/resolv.conf for nameservers
no-resolv
# Interface to bind to
interface=wlan0
# Specify starting_range,end_range,lease_time
dhcp-range=10.0.0.3,10.0.0.20,12h
# dns addresses to send to the clients
server=8.8.8.8
server=8.8.4.4
第三步:添加腳步;
將以下腳本添加到/etc/network/if-up.d/wapstart:
#!/bin/sh
WIRE=eth0
WIFI=wlan0
# Only run script for wired interface
if [ ! "$IFACE" = "$WIRE" ]
then
exit 0
fi
# Setup wireless interface
ifconfig $WIFI up 10.0.0.1 netmask 255.255.255.0
# Start dnsmasq
/etc/init.d/dnsmasq start
#Enable NAT
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
iptables --table nat --append POSTROUTING --out-interface $WIRE -j MASQUERADE
iptables --append FORWARD --in-interface $WIFI -j ACCEPT
# Start the Wireless Access Point service
/etc/init.d/hostapd start
exit 0
將以下腳本添加到/etc/network/if-post-down.d/wapstop:
#!/bin/bash
WIRE=eth0
WIFI=wlan0
# Only run script for wired interface
if [ ! "$IFACE" = "$WIRE" ]
then
exit 0
fi
# Stops Wireless Access Point services
/etc/init.d/hostapd stop
/etc/init.d/dnsmasq stop
# Asked nice the first time...
killall dnsmasq
killall hostapd
ifconfig $WIFI down
為這兩個(gè)腳本加上可執(zhí)行權(quán)限:
chmod +x /etc/network/if-up.d/wapstart
chmod +x /etc/network/if-post-down.d/wapstop
最后一步:使用咯;
ifconfig eth0 down
ifconfig eth0 up
步驟分步閱讀
1
/6
檢查確認(rèn)筆記本網(wǎng)卡支持master模式
首先要安裝一個(gè)iw:yum install iw -y
然后執(zhí)行命令:iw list
在命令執(zhí)行結(jié)果中如果看到了下面的內(nèi)容,就說(shuō)明這張網(wǎng)卡是支持用于ap做路由的
Supported interface modes:
* IBSS
* managed
* AP
* AP/VLAN
* monitor
* mesh point
2
/6
安裝hostapd
通過(guò) yum install hostapd -y 安裝,如果是其它紅帽系列的可以安裝epel的源,或者找一下hostapd的rpm,下載對(duì)應(yīng)自己發(fā)行版的進(jìn)行安裝。其它Linux可以通過(guò)源碼安裝。
3
/6
修改配置文件
# vim /etc/hostapd/hostapd.conf
修改成如下?tīng)顟B(tài)
ctrl_interface=/var/run/hostapd
ctrl_interface_group=wheel
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
wpa_passphrase=ap_password
driver=nl80211
interface=wlan0
hw_mode=g
channel=9
ssid=ap_name
注意修改涉及到的ssid和密碼
4
/6
安裝和配置dhcp
# yum install dhcpd -y
# vim /etc/dhcp/dhcpd.conf
將此文件改成如下:
option domain-name-servers 211.161.45.222,10.141.146.10;
default-lease-time 3600;
max-lease-time 7200;
log-facility local7;
subnet 192.168.7.0 netmask 255.255.255.0 {
range 192.168.7.77 192.168.7.99;
option broadcast-address 192.168.7.255;
option routers 192.168.7.7;
}
注意將第一行的nameserver添加成你isp提供的dns,這樣解析的速度會(huì)快一些,不知道的話就改成谷歌的8.8.8.8好了。subnet 里面設(shè)置的是分配給連接無(wú)線路由的設(shè)備的ip段,可以根據(jù)自己需求進(jìn)行調(diào)整,這里給了192.168.7.77-99
需要注意的是,option routers要寫(xiě)成這臺(tái)機(jī)器的wlan0的ip,這個(gè)是手動(dòng)設(shè)置的
# ifconfig wlan0 192.168.7.7
5
/6
配置SNAT
Linux可以很方便的通過(guò)iptables配置SNAT服務(wù)器,命令如下:
iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -s 192.168.4.0/24 -j ACCEPT
iptables -A FORWARD -d 192.168.4.0/24 -j ACCEPT
其中第一條表示將通過(guò)本機(jī)的轉(zhuǎn)發(fā)數(shù)據(jù)包從eth0(外網(wǎng))這個(gè)網(wǎng)卡發(fā)出去,另外兩條表示只轉(zhuǎn)發(fā)192.168.4.0/24這個(gè)網(wǎng)段過(guò)來(lái)的數(shù)據(jù)包,這個(gè)網(wǎng)段正好是wlan0其它設(shè)備連上本機(jī)以后分配的網(wǎng)段。
還需要在打開(kāi)內(nèi)核的ip轉(zhuǎn)發(fā)功能:
# vim /etc/sysctl.conf
添加或修改這樣一段:
net.ipv4.conf.default.rp_filter = 1
然后執(zhí)行命令
# sysctl -p
6
/6
啟動(dòng)相關(guān)服務(wù)
/etc/init.d/dhcpd start
/etc/init.d/hostapd start
將有線網(wǎng)卡的網(wǎng)口插上網(wǎng)線調(diào)通就可以用其它無(wú)線設(shè)備連接此wifi ap上網(wǎng)了。
網(wǎng)站標(biāo)題:linux命令顯示熱點(diǎn) linux連接熱點(diǎn)
網(wǎng)頁(yè)URL:http://www.rwnh.cn/article4/doppdie.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站、網(wǎng)頁(yè)設(shè)計(jì)公司、微信小程序、服務(wù)器托管、標(biāo)簽優(yōu)化、網(wǎng)站營(yíng)銷(xiāo)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)