《Linux就该这么学》是由全国多名红帽架构师(RHCA)基于最新Linux系统共同编写的高质量Linux技术自学教程,极其适合用于Linux技术入门教程或讲课辅助教材。
分类: LINUX
2016-05-23 06:45:04
deb jessie-backports main contrib non-free
apt-get update apt-get install linux-image-4.3.0-0.bpo.1-amd64 apt-get install linux-headers-4.3.0-0.bpo.1-all-amd64 apt-get install pkg-config apt-get install libssl-dev apt-get install gettext apt-get install openssl apt-get install libnl-genl-3-dev apt-get install libnl-genl-3-200 apt-get install libnl-3-dev apt-get install libnl-3-200 apt-get install hostapd
wget
tar -zxvf hostapd-2.5.tar.gz cd hostapd-2.5 cp defconfig .config使用vi .config命令对该文件进行修改,修改内容如下:
# Use libnl v2.0 (or 3.0) libraries. CONFIG_LIBNL20=y # Use libnl 3.2 libraries (if this is selected, CONFIG_LIBNL20 is ignored) CONFIG_LIBNL32=y # IEEE 802.11n (High Throughput) support CONFIG_IEEE80211N=y保存退出,编译安装:
make make install系统将在/usr/local/bin目录下生成两个文件名为hostapd、hostapd_cli的可执行文件。
cp hostapd.conf /etc/hostapd/ vi /etc/hostapd/hostapd.conf interface=wlan1 driver=nl80211 ssid=LONUXPROBE hw_mode=g channel=7 macaddr_acl=0 auth_algs=3 ignore_broadcast_ssid=0 wmm_enabled=1 ieee80211n=1 ht_capab=[HT40-][SHORT-GI-20][SHORT-GI-40] wpa=2 wpa_passphrase=linuxprobe macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP
vi /etc/default/hostapd DAEMON_CONF="/etc/hostapd/hostapd.conf"
vi /etc/init.d/hostapd DAEMON_SBIN=/usr/local/bin/hostapd并在start)下一行添加如下内容:
sed -i '/\[keyfile\]/a unmanaged-devices=mac:c8:3a:35:cb:18:e0' /etc/NetworkManager/NetworkManager.conf ip addr add 192.168.11.1/24 dev wlan1 echo "1" >/proc/sys/net/ipv4/ip_forward iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE sleep 2在stop)下一行添加如下内容:
sed -i '/^unmanaged-devices=mac:c8:3a:35:cb:18:e0/d' /etc/NetworkManager/NetworkManager.conf echo "0" >/proc/sys/net/ipv4/ip_forward ip addr del 192.168.11.1/24 dev wlan1 iptables -t nat -D POSTROUTING -o wlan0 -j MASQUERADE sleep 2在reload)下一行添加如下内容:
sed -i '/^unmanaged-devices=mac:c8:3a:35:cb:18:e0/d' /etc/NetworkManager/NetworkManager.conf echo "0" >/proc/sys/net/ipv4/ip_forward ip addr del 192.168.11.1/24 dev wlan1 iptables -t nat -D POSTROUTING -o wlan0 -j MASQUERADE sed -i '/\[keyfile\]/a unmanaged-devices=mac:c8:3a:35:cb:18:e0' /etc/NetworkManager/NetworkManager.conf ip addr add 192.168.11.1/24 dev wlan1 echo "1" >/proc/sys/net/ipv4/ip_forward iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE sleep 2保存退出,(根据自己情况设定参数mac和ip)对脚本文件进行重新配置:
systemctl daemon-reload
apt-get install dnsmasq
vi /etc/dnsmasq.conf resolv-file=/etc/resolv.dnsmasq.conf server=/cn/114.114.114.114 server=/taobao.com/114.114.114.114 server=/google.com/8.8.8.8 listen-address=127.0.0.1,192.168.11.1 dhcp-range=192.168.11.50,192.168.11.150,12h dhcp-option=3,192.168.11.1 dhcp-option=6,192.168.11.1 cache-size=1024 conf-dir=/etc/dnsmasq.d
vi /etc/resolv.dnsmasq.conf nameserver 114.114.114.114 nameserver 223.5.5.5 nameserver 223.6.6.6
vi /etc/resolv.conf nameserver 127.0.0.1
systemctl enable dnsmasq.service systemctl disable hostapd.service开启和关闭两项服务,之后在需要使用热点模式时使用命令:
systemctl start hostpad.serive用户即可使用热点名为LINUXPROBE,密码为linuxprobe,网关地址和DNS均为192.168.11.1的80211N协议无限热点进行上网连接啦!
免费提供最新Linux技术教程书籍,为开源技术爱好者努力做得更多更好: