Home
Categories
WIKI
Topic
User
LANGUAGE:
中文
English
[转载][亲测]新的更简单的电脑分享wifi给手机用!
Experiences and Insight
1881
views ·
2
replies ·
To
floor
Go
qq200600
deepin
2013-08-21 05:07
Author
【以下所有操作都建立在拥有无线网卡的电脑上】
1.安装 dhcp3-server 和 hostapd
2.在桌面右键新建文本文档命名mywifi.sh,然后右键属性勾上可执行
3.在命令行里面运行,输入密码,然后享受吧 哈哈
Copy the Code
mywifi.sh里面的内容:
#!/bin/bash
#● ai hostapd dhcp3-server
iw list|grep '* AP'
[ $? -ne 0 ] && echo "No device support AP mode." && exit
sudo ifconfig wlan0 192.168.0.1 netmask 255.255.255.0
sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables -t nat -A POSTROUTING -j MASQUERADE
sudo pkill -9 dhcpd
if [ ! -f /etc/apparmor.d/disable/usr.sbin.dhcpd ]; then
sudo ln -s /etc/apparmor.d/usr.sbin.dhcpd /etc/apparmor.d/disable/
sudo /etc/init.d/apparmor restart
fi
cat > /tmp/dhcpd.conf << EOF
default-lease-time 600;
max-lease-time 7200;
subnet 192.168.0.0 netmask 255.255.255.0
{
range 192.168.0.2 192.168.0.250;
option domain-name-servers 8.8.8.8;
option routers 192.168.0.1;
}
EOF
sudo dhcpd wlan0 -cf /tmp/dhcpd.conf -pf /var/run/dhcp-server/dhcpd.pid
cat > /tmp/hostapd.conf << EOF
interface=wlan0
driver=nl80211
ssid=`hostname`-hostapd
hw_mode=g
channel=11
auth_algs=1
# 如果需要开启密码,wpa=1。
wpa=0
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
EOF
sudo hostapd -d /tmp/hostapd.conf
Copy the Code
密码可自行更改哦!
成功后命令行里面会显示类似这种:
wlan0: STA 10:68:3f:3d:3c:04 IEEE 802.11: authentication OK (open system)
wlan0: STA 10:68:3f:3d:3c:04 MLME: MLME-AUTHENTICATE.indication(10:68:3f:3d:3c:04, OPEN_SYSTEM)
wlan0: STA 10:68:3f:3d:3c:04 MLME: MLME-DELETEKEYS.request(10:68:3f:3d:3c:04)
authentication reply: STA=10:68:3f:3d:3c:04 auth_alg=0 auth_transaction=2 resp=0 (IE len=0)
mgmt::auth cb
wlan0: STA 10:68:3f:3d:3c:04 IEEE 802.11: authenticated
mgmt::assoc_req
association request: STA=10:68:3f:3d:3c:04 capab_info=0x421 listen_interval=1
new AID 1
wlan0: STA 10:68:3f:3d:3c:04 IEEE 802.11: association OK (aid 1)
mgmt::assoc_resp cb
wlan0: STA 10:68:3f:3d:3c:04 IEEE 802.11: associated (aid 1)
wlan0: AP-STA-CONNECTED 10:68:3f:3d:3c:04
wlan0: STA 10:68:3f:3d:3c:04 MLME: MLME-ASSOCIATE.indication(10:68:3f:3d:3c:04)
wlan0: STA 10:68:3f:3d:3c:04 MLME: MLME-DELETEKEYS.request(10:68:3f:3d:3c:04)
wlan0: STA 10:68:3f:3d:3c:04 RADIUS: starting accounting session 521367BC-00000000
IEEE 802.1X: Ignore STA - 802.1X not enabled or forced for WPS
nl80211: Event message available
nl80211: New station 10:68:3f:3d:3c:04
wlan0: Station 10:68:3f:3d:3c:04 has been active 0s ago
Copy the Code
Reply
Like 0
Favorite
View the author
All Replies
badbye
deepin
2013-08-22 19:18
#1
No device support AP mode.
第一步就死了, 好伤心~
Reply
Like 0
View the author
badbye
deepin
2013-08-22 19:20
#2
话说我的无线网卡一直识别不出来,虽然可以无线上网。顺便求助~
Reply
Like 0
View the author
Please
sign
in first
New Thread
Popular Ranking
Change
Updating 25 Beta to 25 Release
Deepin from 23.1 to 25
Deepin 25 release - upgrading?
The graphics card is not worki
Various Thoughts after 3 Weeks
Popular Events
More
密码可自行更改哦!
成功后命令行里面会显示类似这种: