一、这个是使用别人写的一个GUI来配置,:http://hi.baidu.com/lexiangtaotao/item/5d4e87f22db132c70cd1c86f
二、使用hostapd配置:http://blog.csdn.net/jiguanghoverli/article/details/8110520
三、使用hostapd和dhcp3-server配置:http://www.cnblogs.com/easonliu/archive/2012/11/07/2759661.html
四、hostapd简介:http://blog.csdn.net/zhenwenxian/article/details/6658507
五、官网(推荐):http://linuxwireless.org/en/users/Documentation/hostapd
************************************
Ubuntu共享WiFi(AP)给Android方法【修正版】
硬件配置:
电脑操做系统:Ubuntu 12.04 LTS
手机系统: 联想 A780,android 4.0
Android是不支持Ad-hoc模式的WiFi.Windows 7软AP一个仍是比较简单的.本文介绍在Ubuntu下实现软AP.(须要你的无线网卡支持AP哈)
使用工具hostapd,dnsmasq.个人环境是Ubuntu11.10或ubuntu12.04;手机Android 2.3.5;网卡ath5k.有线网络使用静态的IP.
一、首先,系统是Ubuntu 11.10或者Ubuntu 12.04,安装软件:
sudo apt-get install hostapd dnsmasq
/**
此步不用动
二、配置网络端口: sudo gedit /etc/network/interfaces文件,内容以下:
auto eth0
iface eth0 inet static
address 192.168.1.100 # ip地址,本身修改
netmask 255.255.255.0 # 子网掩码,本身修改
gateway 192.168.1.1 # 网关,本身修改
auto lo
iface lo inet loopback
**/
三、配置hostapd: sudo gedit /etc/
hostapd/hostapd.conf 内容以下
(注意:每行末,不要留空格)
interface=wlan0
driver=nl80211
ssid=wbyxu#
ssid 能够改为你喜欢的名字
hw_mode=g
channel=11
dtim_period=1
rts_threshold=2347
fragm_threshold=2346
macaddr_acl=0
auth_algs=3
ieee80211n=0
wpa=3
wpa_passphrase=12345678#
自行设置密码,密码后不要留空格
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
四、配置dns: sudo gedit /etc/dnsmasq.conf 内容以下
(注意:每行末的注释要去掉)
interface=wlan0
bind-interfaces #这个是只监听wlan0,没有之会检测全部卡
except-interface=lo
dhcp-range=10.0.0.10,10.0.0.110,6h #设置dhcp地址范围,即租借时间6小时
#address=/#/10.0.0.1 #这个会把#(表明全部网址)的dns到10.1.1.1这个地址
dhcp-option=3,10.0.0.1 #为手机配置网关 (此处参考)
dhcp-option=6,202.114.128.2#为手机配置dns,请本身修改成外网的dns地址(此处参考)
五、编辑启动脚本: sudo gedit
/usr/bin/myap 内容以下:
#! /bin/sh
# 为无线添加路由规则
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t nat -A POSTROUTING -s 10.0.0.0/8 -o eth0 -j MASQUERADE
iptables -A FORWARD -s 10.0.0.0/8 -o eth0 -j ACCEPT
iptables -A FORWARD -d 10.0.0.0/8 -m conntrack --ctstate ESTABLISHED,RELATED -i eth0 -j ACCEPT
#dnsmasq与named通常状况下bind的named会占了53端口,
# 而后dnsmasq会启动不了,因此我用killall named来杀了named再启动dnsmasq。
killall named
killall hostapd
ifconfig wlan0 10.0.0.1
#“-B”后台运行,以后的hostapd.conf须要指名路径.
hostapd -B /etc/
hostapd/hostapd.conf
/etc/init.d/dnsmasq restart
# dnsmasq启动后会出现电脑忽然上不了网,
# 由于dnsmasq更改了/etc/resolv.conf的缘由。能够在/etc/resolv.conf加一行
# nameserver x.x.x.x
#填入DNS服务器地址,根据本身的状况修改。
echo "nameserver 202.114.128.2" >> /etc/resolv.conf
六、修改/usr/bin/myap权限:
sudo chmod a+x /usr/bin/myap
七、最后还要注意确保系统打开转发功能
sudo su
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
echo 1 >/proc/sys/net/ipv4/ip_forward
exit
8. 想共享wifi时,请保证电脑能上网,而后运行
sudo myap
至此,电脑上的设置完成,最好重启一下.
手机上设置WiFi不使用静态IP就能够了.