|
1、安装Hostapd,dnsmasq:
- sudo apt-get install hostapd dnsmasq
复制代码 2、然后在/etc/dnsmasq.conf末加入(自己修改IP和网段,这个文件是已存在的,很详细的配置文件,但是所有行都加入了#号注释掉)
- interface=wlan0
- dhcp-range=10.0.0.2,10.0.0.5,255.255.255.0,12h
复制代码 3、新建/etc/hostapd/hostapd.conf,加入如下内容:
- interface=wlan0
- hw_mode=g
- channel=10
- auth_algs=1
- wpa=2
- wpa_key_mgmt=WPA-PSK
- wpa_pairwise=CCMP
- rsn_pairwise=CCMP
- wpa_passphrase=wifi密码
- ssid=wifi名字
复制代码 4、修改/etc/sysctl.conf,更改(如果有这一行,把#号去掉就行):
5、将下面脚本加入到/etc/rc.local的exit 0前面位置: - ifconfig wlan0 down
- ifconfig wlan0 10.0.0.1 netmask 255.255.255.0 up
- iwconfig wlan0 power off
- service dnsmasq restart
- hostapd -B /etc/hostapd/hostapd.conf & > /dev/null 2>&1
- sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
- sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
- sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
复制代码
|
|