centos7上架设无线AP完整步骤

kevin.Zhu 发布于:2018-10-15 20:16 分类:Linux系统运维  有 30 人浏览,获得评论 0 条  

环境:centos7, 网卡两张 一张无线网卡用于做AP
软件:hostapd 用于将网卡设置成Ap模式,dnsmasq提供Dns和Dhcp服务

过程: 
1. 先检查服务器防火墙,条件允许的话 可以先关掉

2. 设置无线网卡,配置好IP地址并且打开。如下: 

TYPE=Ethernet
BOOTPROTO=static
#DEFROUTE=yes
#IPV4_FAILURE_FATAL=no
#IPV6INIT=yes
#IPV6_AUTOCONF=yes
#IPV6_DEFROUTE=yes
#IPV6_FAILURE_FATAL=no
#NAME=static-wlp2s0
#UUID=a036678e-8fdf-48f3-8693-961bb6326i744 
HWADDR="14:cf:92:05:37:a0"
DEVICE=wlp0s26u1u5
ONBOOT=yes
IPADDR=192.168.11.1
NETMASK=255.255.255.0
PREFIX=24
#GATEWAY=192.168.10.254                              #其他用不着注释掉
#DNS1=127.0.0.1
#DNS2=192.168.10.254
#IPV6_PEERDNS=yes
#IPV6_PEERROUTES=yes
3. 设置hostapd /etc/hostapd/hostapd.conf, 配置好启动,最小化设置如下: 

# Some usable default settings...
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0

# Uncomment these for base WPA & WPA2 support with a pre-shared key
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
# wpa_pairwise=CCMP
rsn_pairwise=CCMP

# DO NOT FORGET TO SET A WPA PASSPHRASE!!
wpa_passphrase=111111111        #无线密码

# Most modern wireless drivers in the kernel need driver=nl80211
driver=nl80211          #驱动

# Customize these for your local configuration...
interface=wlp0s26u1u5
hw_mode=g               #a,b,g,n 有些老网卡不支持n
channel=1
ssid=TV-devSrv          #ssid
4. 设置dnsmasq的dhcp 与dns
# 指定接口,指定后同时附加lo接口,可以使用'*'通配符
interface=wlp2s0,127.0.0.1

# 绑定接口
bind-interfaces
# DHCP地址池 从172.16.0.100到172.16.0.200, 必须与wlp2s0在同一网段,wlp2s0会自动作为网关

dhcp-range=172.16.0.100,172.16.0.200,255.255.255.0,1h