Centos7.5使用hostapd + dhcpd + nftables搭建Linux热点(AP)
Centos7.5使用hostapd + dhcpd + nftables搭建Linux热点(AP)
前言
因为 NetworkManager 的开热点功能不好用,所以网上查了些资料加实验,搞了一下。全程使用root或sudo。
这样做的意义是:以前我们都是使用网线连着服务器和终端进行测试。现在只要终端通过无线网连接到服务器,因为ap分配给终端的ip和服务器
的ip在同一网段,就可以直接访问服务器以及请求服务,做到无线连接。
1、先看硬件是否支持AP
iw list
如果里面 Supported interface modes: 有"AP" 那么意味着你的网卡支持。
2、安装hostapd + dhcpd + nftables
在安装之前,请确保你的 CentOS 已经使用了 epel 源:
yum install epel-release -y
yum install hostapd dhcp nftables -y
3、整体逻辑
在配置过程中有些报错,报错贴在第6节。基本逻辑为:
- 使用 nmcli 将无线网卡托管(默认是NetworkManager 管理的,需要抢到控制权)
- 为无线网卡配置一个 IP
- 打开 dhcp功能
- 启动 hostapd
4、配置
4.1、配置hostapd
默认配置文件在 /etc/hostapd/hostapd.conf 。这里只讲最基本的配置,深入的自行研究。
vim /etc/hostapd/hostapd.conf
#
# This will give you a minimal, insecure wireless network.
#
# DO NOT BE SATISFIED WITH THAT!!!
#
# A complete, well commented example configuration file is
# available here:
#<