hostapd成功配置热点,共享一下

上网、浏览、聊天、下载等
回复
头像
cwll
帖子: 190
注册时间: 2011-07-05 11:10

hostapd成功配置热点,共享一下

#1

帖子 cwll » 2013-03-28 16:28

1.查看自己的无线网卡信息:

代码: 全选

$ hwinfo --netcard
查看是否支持ap功能,如果有AP字样,说明支持

代码: 全选

$ sudo apt-get install iw
$ iw list
2.安装hostapd,反正提示依赖什么包就安装什么包

代码: 全选

$ sudo apt-get install libnl1 libnl-dev libnl-doc
$ sudo apt-get install libssl-dev
$sudo apt-get install bridge-utils
$sudo apt-get install hostapd
$sudo cp /usr/share/doc/hostapd/examples/hostapd.conf.gz   /etc/hostapd/
$sudo gzip -d /etc/hostapd/hostapd.conf.gz
$vi /etc/hostapd/hostapd.conf
hostapd.conf内容如下:
interface=wlan0
bridge=br0
driver=nl80211
ssid=ssa
hw_mode=g
channel=11
dtim_period=1
rts_threshold=2347
fragm_threshold=2346
auth_algs=3
wpa=1
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
rsn_pairwise=CCMP
3.设置网卡桥接模式
下面这个文件最后备份一下

代码: 全选

$sudo vi /etc/network/interfaces
把里面内容替换成如下 (172.16.16.178是eth0原来的地址,意思就是br0现在成了该主机的对外网卡,eth0是br0桥接的端口之1
所以br0在这里的设置完全是和eth0一样的)
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto br0
iface br0 inet static
bridge_ports eth0
address 172.16.16.X ##这里是你的IP
netmask 255.255.255.0
network 172.16.16.0
broadcast 172.16.16.255
gateway 172.16.16.G ##这里是你的网关
编辑完成后保存

代码: 全选

$sudo /etc/init.d/networking restart
最好是重启一下。
其实到这里网应该已经通了,ping 一下运营商的nds服务器

代码: 全选

$ping 8.8.8.4.4
应该显示可以通了。但是

代码: 全选

$ping www.baidu.com
应该是不能通的。
4.为主机重新设置dns
这里不在/etc/resolve.conf里改,因为重启后就没有了。下面这个文件重启后不会被改掉。

代码: 全选

$sudo vi /etc/resolvconf/resolv.conf.d/tail
这个文件默认应该是没有的,保存
nameserver 202.100.64.68
保存后ping 下www.baidu.com,应该可以通了
5.手机与电脑eth0设置
电脑端eth0不用设置IP地址了。把原来设置的删掉。
手机端要手动设置IP地址,为172.16.16.Y,其它设置都一样
试一下,手机应该可以上网了。
y_tm
帖子: 18
注册时间: 2012-02-02 14:44

Re: hostapd成功配置热点,共享一下

#2

帖子 y_tm » 2013-04-14 0:25

我设置了,没搜到手机wifi。。。
y_tm
帖子: 18
注册时间: 2012-02-02 14:44

Re: hostapd成功配置热点,共享一下

#3

帖子 y_tm » 2013-04-14 0:28

ytm@ytm:~$ hostapd -d /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
nl80211: Register Action command failed: ret=-1 (Operation not permitted)
nl80211: Register Action match - hexdump(len=1): 06
nl80211: Failed to register Action frame processing - ignore for now
nl80211: Add own interface ifindex 7
nl80211: Add own interface ifindex 3
Could not set interface wlan0 flags: Permission denied
nl80211 driver initialization failed.
ELOOP: remaining socket: sock=4 eloop_data=0x18fb1d0 user_data=0x18fb9f0 handler=0x433940
ELOOP: remaining socket: sock=6 eloop_data=0x18fe0f0 user_data=(nil) handler=0x43cd90
ytm@ytm:~$ sudo hostapd -d /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
nl80211: Register Action command failed: ret=-114 (Operation already in progress)
nl80211: Register Action match - hexdump(len=1): 06
nl80211: Failed to register Action frame processing - ignore for now
nl80211: Add own interface ifindex 7
nl80211: Add own interface ifindex 3
nl80211: Failed to set interface 3 to mode 3: -95 (Operation not supported)
nl80211: Failed to set interface 3 to mode 3: -95 (Operation not supported)
nl80211: Interface mode change to 3 from 0 failed
nl80211: Failed to set interface wlan0 into AP mode
nl80211 driver initialization failed.
ELOOP: remaining socket: sock=4 eloop_data=0x117e1d0 user_data=0x117e9f0 handler=0x433940
ELOOP: remaining socket: sock=6 eloop_data=0x11810f0 user_data=(nil) handler=0x43cd90

lw list
Supported RX frame types:
* IBSS: 0x00d0
* managed: 0x0040 0x00d0
* AP: 0x0000 0x0020 0x0040 0x00a0 0x00b0 0x00c0 0x00d0
* AP/VLAN: 0x0000 0x0020 0x0040 0x00a0 0x00b0 0x00c0 0x00d0
* mesh point: 0x00b0 0x00c0 0x00d0
* P2P-client: 0x0040 0x00d0
* P2P-GO: 0x0000 0x0020 0x0040 0x00a0 0x00b0 0x00c0 0x00d0
这是什么情况!
头像
cwll
帖子: 190
注册时间: 2011-07-05 11:10

Re: hostapd成功配置热点,共享一下

#4

帖子 cwll » 2013-04-14 8:41

(Operation already in progress)
安装完hostapd后,会开机自动运行。看这个提示好像是说已经在运行了。
你先用

代码: 全选

sudo /etc/init.d/hostapd stop
再试试
y_tm
帖子: 18
注册时间: 2012-02-02 14:44

Re: hostapd成功配置热点,共享一下

#5

帖子 y_tm » 2013-04-15 7:38

cwll 写了:(Operation already in progress)
安装完hostapd后,会开机自动运行。看这个提示好像是说已经在运行了。
你先用

代码: 全选

sudo /etc/init.d/hostapd stop
再试试
ytm@ytm:~$ sudo /etc/init.d/hostapd stop
[sudo] password for ytm:
ytm@ytm:~$ sudo hostapd -d /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
nl80211: Register Action command failed: ret=-114 (Operation already in progress)
nl80211: Register Action match - hexdump(len=1): 06
nl80211: Failed to register Action frame processing - ignore for now
nl80211: Add own interface ifindex 3
nl80211: Failed to set interface 3 to mode 3: -95 (Operation not supported)
nl80211: Failed to set interface 3 to mode 3: -95 (Operation not supported)
nl80211: Interface mode change to 3 from 0 failed
nl80211: Failed to set interface wlan0 into AP mode
nl80211 driver initialization failed.
ELOOP: remaining socket: sock=4 eloop_data=0x7f41d0 user_data=0x7f49f0 handler=0x433940
ELOOP: remaining socket: sock=6 eloop_data=0x7f70f0 user_data=(nil) handler=0x43cd90

还是不行
nasta
帖子: 13
注册时间: 2009-07-16 0:33

Re: hostapd成功配置热点,共享一下

#6

帖子 nasta » 2013-04-30 9:27

如果编辑/etc/network/interface的话 networkmanager就不去管理有线连接了 蛋疼
回复