校园网Ubuntu14.04配置无线网卡TPLINK WN725N V2(USB Wifi)为热点的方案

包含网卡/无线网的网络问题和ADSL/校园网/宽带拨号支持及代理/共享等网络使用问题
回复
minhu314
帖子: 9
注册时间: 2006-11-04 21:32

校园网Ubuntu14.04配置无线网卡TPLINK WN725N V2(USB Wifi)为热点的方案

#1

帖子 minhu314 » 2015-06-08 11:21

大家好,入论坛N年第3次发贴(每次发贴都是经验总结),向那些乐于分享互助的童鞋学习:-)

下面讲诉一下本人在校园网中配置usb无线网卡为热点的几天吐血历程。

如果是高手达人路过请指点一二补充、完善本方案,如果是遇到类似问题的童鞋希望对您有所助益。

一、环境背景
1、某大校园网,采用锐捷认证上网
2、台式机(配有1个有线网卡),配置Ubuntu14.04系统(64位),采用mentohust上网。
3、笔记本(没有多余上网帐号,因为现有帐号被台式机用了)。
4、在XX逊上掏了一个USB无线网卡(TP-LINK TL-WN725N v2),该网卡在windows系统上有厂商提供的无线AP软件易于使用,但是Linux下无厂商提供驱动和创建无线热点的软件。
二、目标
让台式机插上USB无线网卡,然后设置无线热点让笔记本上网。
三、过程
1. 吐血经历
搜遍谷歌、百度相关网页,尝试各种现成方法均以失败告终(省略N字)。
因时间所限,下面给出最终成功的关键经验和关键步骤。
2. 关键经验和关键步骤
2.1. Ubuntu14.04直接就支持识别该网卡的驱动了,插上去就可以去联外面的热点(如果有密码),好不好用不知道,因为下面一点。
2.2. 网络上有很多该网卡的驱动安装方法,本人一上来直接参考网络上的网卡驱动安装方法安装了驱动,后来还更换了很多驱动~~~~
2.3 Ubuntu本身提供了建Ad-hoc热点的功能(网络上有很多教程),但是我只连上一次再重启就不行了,不知道是不是后来自己装了各种驱动导致错误的原因,反正Ad-hoc就无法用了,另外笔记本连上Ad-hoc热点特别慢。
2.4 总归是无法建Access Point热点,强制去建就会出现类似“Access Point Mode Is Not Supported By This Device“的提示,不论是用ubuntu自己的网络管理工具还是kde-nm-connection-editor管理工具,结果是一样的——热点建不起来。原因大概如某童鞋说的,驱动或芯片不支持,windows上可以是因为附加了增强软件。
2.5 成功步骤(一些是E文复制,没空翻译,童鞋们就当练习E文水平了)
++++++++++++++++++++++++++++++++++++++++++
Steps that helped me to configure a non-bridged AP:
1. Install hostapd & dhcp server
apt-get install hostapd udhcpd

2. Edit /etc/udhcpd.conf, set its contents like this:
start 192.168.42.2 # This is the range of IPs that the hostspot will give to client devices.
end 192.168.42.20
interface wlan0 # The device uDHCP listens on.
remaining yes
opt dns 8.8.8.8 4.4.4.4 # The DNS servers client devices will use.
opt subnet 255.255.255.0
opt router 192.168.42.1 # The Pi's IP address on wlan0 which we will set up shortly.
opt lease 864000 # 10 day DHCP lease time in seconds

3. Edit /etc/default/udhcpd, set the following line to be like this:
#DHCPD_ENABLED="no"

4. Set wlan0 static IP, edit /etc/network/interfaces, contents should look like this:
auto lo
iface lo inet loopback
#下面两行不需要,如果添加Ubuntu就不会用界面上的网卡管理工具来管理网络了,我们还是让ubuntu管理有线网卡吧,否则mentohust无法通过认证网络,原因不明,希望高手指点一二。
#auto eth0
#iface eth0 inet dhcp


#下面手动配置无线网卡ip,配置dhcp服务启动,让Ubuntu网卡管理工具脱离网卡的管理。
auto wlan0
iface wlan0 inet static
address 192.168.42.1
netmask 255.255.255.0
post-up service udhcpd start

#allow-hotplug wlan0
#iface wlan0 inet manual
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
#iface default inet dhcp

5. Replace hostapd with a modified binary:下面5行只能参考,因为下载的文件在我的Ubuntu14.04上无法使用,我们后面需要下载源代码来编译所需文件
wget http://www.daveconroy.com/wp3/wp-conten ... ostapd.zip
unzip hostapd.zip
mv /usr/sbin/hostapd /usr/sbin/hostapd.bak
mv hostapd /usr/sbin/hostapd
chmod 755 /usr/sbin/hostapd

我最后去这里(http://www.realtek.com.tw/downloads/dow ... Down=false)下载到一个驱动(下了好几个,一个一个试编译安装,找到一个可用的RTL8192CU,似乎和原网卡的芯片(网友说是chipset RTL8188EU)并不完全一致,但厂家一致)

Alternative link: https://www.dropbox.com/s/u4lt7k6ko4i6589/hostapd.zip
NOTE: if you want to compile the binary for yourself, then go here(http://www.realtek.com.tw/downloads/dow ... Down=false) & download RTL8192CUS(原文说的这个驱动我没找到) driver. Navigate inside zip to the wpa_supplicant_hostapd/wpa_supplicant_hostapd-0.8/hostapd and run: make, make install, then copy as above.

采用下面的方式安装驱动,需要进入下载的驱动路径(需将驱动解压缩,驱动解压后有的路径下还有压缩包还要解压)
/文档/Ubuntu/TP-LINK_TL-WN725N/RTL8188C_8192C_USB
_linux_v4.0.2_9000.20130911/wpa_supplicant_hostapd/wpa_supplicant_hostapd-0.8_rtw_r7475.20130812/hostapd$

编译和安装命令:
make
sudo make install
这下我们就编译出了这个hostapd文件,这个文件就是创建无线热点的关键。
mv hostapd /usr/sbin/hostapd
chmod 755 /usr/sbin/hostapd

6. Edit /etc/hostapd/hostapd.conf, contents should look like (change "RPI_AP" to the desired AP name, "AP_PASSWORD" - to desired password):
CODE: SELECT ALL
interface=wlan0
driver=rtl871xdrv
ssid=RPI_AP
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=AP_PASSWORD
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
macaddr_acl=0

7. Edit /etc/default/hostapd, set the line to be:
DAEMON_CONF="/etc/hostapd/hostapd.conf"

8. Run hostapd:
#上面是编写配置文件,然后可以启动这个hostapd服务了
service hostapd restart
#如果顺利,你会看到,先停止该服务成功[ok],然后再启动该服务成功[ok]。如果失败,就会出现红色的[fail]。
#补充:有时候上面正确的hostapd也不能成功启动服务啊,原因似乎是Ubuntu还在管理网卡,所以你可以reooot一下让Ubuntu的网卡管理工具脱离管理网卡,或者把usb网卡拔掉再插上试试。。。。吐血啊。

9. Allow hostapd to be run everytime on boot:
update-rc.d hostapd enable

10. Reboot your RPi
reboot

Finished! You should now have a fully working AP (with WPA2-PSK security) that you can connect to.
I have successfully tested with my Android phone.
至此笔记本可以看到台式机创建的热点并连接成功了!!!

但是,连上后没有internet,尝试了一些配置ap的软件
(1)Ap-hotspot:失败
(2)create_ap(https://github.com/oblique/create_ap),还是失败。

###################################################################################################################
还有一个方案就是iptable手工配置共享上网,也许这是最好的热点方案,能不能通过锐捷认证就不知道了,网络这块不熟悉没时间折腾,请路过高手指点一二!
###################################################################################################################

:em20 本来就此作罢,但是今天突然想起来可以试试代理服务器
安装代理服务器
sudo apt-get install squid
配置 squid3
sudo vim /etc/squid3/squid.conf
搜索此句
http_access deny all
修改为
http_access allow all
启动/重启squid3
sudo service squid3 restart
注意: squid的http默认代理端口为 3128

在笔记本上配置代理服务器,连接上网,成功!!! :em05

回头看看,浪费了我不少宝贵时间才搞出了一个小小的usb网卡热点,不免有些伤心,但是如果能让后来的人少走弯路,我也不枉此番尝试了。+++++++++++++++++++++++++++++++++++++++++++
四、重要的参考文献
1、successfully configured the TP-Link TL-WN725N V2 WiFi module (chipset RTL8188EU) as an AP (access point).
https://www.raspberrypi.org/forums/view ... 91&t=54946
2、Is it possible to run rtl8188eu in ap mode?
http://askubuntu.com/questions/630220/i ... in-ap-mode
3、Wifi Hotspot: Access Point Mode Is Not Supported By This Device
http://ubuntuhandbook.org/index.php/201 ... supported/
回复